---
schema_version: "1"
id: e5d38d1440173a1334f1f9972fec52c29df6e0d8259d72b4bb9457f74574fd3b
title: Digital Commerce API Response Optimization
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/industries/cme/guides/comms-t-digital-commerce-api-response-optimization.md
canonical_url: https://developer.salesforce.com/docs/industries/cme/guide/comms-t-digital-commerce-api-response-optimization.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: ac570a8e27bdab34191f1384df55e7d9e5c0a9db78434faaf800fd2e3fde60f6
products:
  - Communications, Media, Energy and Utilities APIs (Managed Package)
  - Industries Developer Documentation
---
# Digital Commerce API Response Optimization

You can request specific nodes in the response from the following Digital Commerce APIs by creating a DataRaptor interface, a DataRaptor transformer, and a post hook for the API response handler.

- AssetToBasket

- BasketOperations

- ConfigureOffer

- GetOffers

- GetOfferDetails

You will need to specify the nodes you want to include in the API response. Specifying specific nodes in the API call reduces the verbosity of the API response, thereby decreasing overhead and bandwidth requirements.

The following example instructions use the GetOffers API and specify the offers:offerType, offers:priceResult:UnitPrice, and offers:ProductCode nodes in the response.

To reduce the size of Digital Commerce API responses:

1.  Go to the Vlocity DataRaptor tab in your org and click **New**.

2.  In the Create Vlocity DataRaptor Interface window, enter a unique name for the DataRaptor interface, such as OffersTransformer.

3.  From the **Interface Type** list, select **Transform**.

4.  From the **Input Type** and **Output Type** lists, select **JSON** and click **Save**. The DataRaptor transformer is displayed on the Vlocity DataRaptor Interface page.

    ![Create Vlocity DataRaptor Interface](https://developer.salesforce.com/docs/media/createdataraptortransform.png)

5.  Click + to add input and output JSON paths (nodes).

6.  In **Input JSON Path** and **Output JSON Path**, enter a valid JSON path from the API's response, such as `offers:offerType`.

7.  From the **Output Data Type** list, select the data type for the node, such as **String**.

    ![Output JSON Path](https://developer.salesforce.com/docs/media/addjsonpathsfordataraptortransform.png)

8.  Click **Save** and then click + to add more nodes as needed.

    ![DataRaptor interface OffersTransformer](https://developer.salesforce.com/docs/media/offerstransformerdataraptorwithjsonpaths.png)

9.  Use sample input to test the DataRaptor transformer. The following sample input to GetOffers should return a transformed response similar to the following example output.

    Sample GetOffers input:

    ```nolang
    {
      "contextKey": "b50d669c29ef610a5b9ba6b4cd734258",
      "offers": [
        {
          "addtocart": {
            "rest": {
              "params": {
                "basketAction": "AddWithNoConfig",
                "offer": "accessories"
              },
              "link": "v3/catalogs/mobiles/basket",
              "method": "POST"
            }
          },
          "offerDetailsAction": {
            "rest": {
              "params": {},
              "method": "GET",
              "link": "/v3/catalogs/mobiles/offers/accessories"
            },
            "remote": {
              "params": {}
            },
            "client": {
              "records": [],
              "params": {}
            }
          },
          "Name": "accessories",
          "Description": "accessories",
          "ProductCode": "accessories",
          "Attachments": null,
          "offerType": "Product"
        },
        {
          "addtocart": {
            "rest": {
              "params": {
                "basketAction": "AddWithNoConfig",
                "offer": "FastCharger"
              },
              "link": "v3/catalogs/mobiles/basket",
              "method": "POST"
            }
          },
          "offerDetailsAction": {
            "rest": {
              "params": {},
              "method": "GET",
              "link": "/v3/catalogs/mobiles/offers/FastCharger"
            },
            "remote": {
              "params": {}
            },
            "client": {
              "records": [],
              "params": {}
            }
          },
          "priceResult": [
            {
              "adjustments": [],
              "overrides": [],
              "chargeamount": 10,
              "baseamount": 10,
              "Amount__c": 10,
              "IsVirtualPrice__c": false,
              "IsBasePrice__c": true,
              "effectiveuntildatespec": null,
              "effectivefromdatespec": null,
              "SubType__c": "Standard",
              "Type__c": "Price",
              "RecurringFrequency__c": null,
              "ChargeType__c": "One-time",
              "DisplayText__c": "fc",
              "UnitPrice": 10
            }
          ],
          "Name": "FastCharger",
          "Description": "FastCharger",
          "ProductCode": "FastCharger",
          "Attachments": null,
          "offerType": "Product"
        },
        {
          "addtocart": {
            "rest": {
              "params": {
                "basketAction": "AddWithNoConfig",
                "offer": "S10"
              },
              "link": "v3/catalogs/mobiles/basket",
              "method": "POST"
            }
          },
          "offerDetailsAction": {
            "rest": {
              "params": {},
              "method": "GET",
              "link": "/v3/catalogs/mobiles/offers/S10"
            },
            "remote": {
              "params": {}
            },
            "client": {
              "records": [],
              "params": {}
            }
          },
          "priceResult": [
            {
              "adjustments": [],
              "overrides": [],
              "chargeamount": 500,
              "baseamount": 500,
              "Amount__c": 500,
              "IsVirtualPrice__c": false,
              "IsBasePrice__c": true,
              "effectiveuntildatespec": null,
              "effectivefromdatespec": null,
              "SubType__c": "Standard",
              "Type__c": "Price",
              "RecurringFrequency__c": null,
              "ChargeType__c": "One-time",
              "DisplayText__c": "one time base",
              "UnitPrice": 500
            },
            {
              "adjustments": [],
              "overrides": [],
              "chargeamount": 50,
              "baseamount": 50,
              "Amount__c": 50,
              "IsVirtualPrice__c": false,
              "IsBasePrice__c": true,
              "effectiveuntildatespec": null,
              "effectivefromdatespec": null,
              "SubType__c": "Standard",
              "Type__c": "Price",
              "RecurringFrequency__c": "Monthly",
              "ChargeType__c": "Recurring",
              "DisplayText__c": "s10 rec base"
            }
          ],
          "Name": "S10",
          "Description": "S10",
          "ProductCode": "S10",
          "Attachments": null,
          "offerType": "Product"
        }
      ],
      "errorCode": "INVOKE-200",
      "error": "OK"
    }
    ```

    Expected reduced output:

    ```nolang
    {
      "offers": [
        {
          "offerType": "Product",
          "ProductCode": "accessories"
        },
        {
          "offerType": "Product",
          "ProductCode": "FastCharger",
          "UnitPrice": 10
        },
        {
          "offerType": "Product",
          "ProductCode": "S10",
          "UnitPrice": 500
        }
      ]
    }
    ```

10. Create a post hook for the response handler to transform responses from getOffers.

    Sample post hook:

    ```nolang
    Object offers = output.get('offers');
    Map<String, Object> bodyData = new Map<String, Object> {
    'bulkUpload' => false,
    'bundleName' => 'OffersTransformer', //name of the transformer
    'debug' => false,
    'objectList' => new List<Object> { output }
    };
    Map<String, Object> re = (Map<String, Object>)DRGlobal.processPost(bodyData);
    Map<String, Object> resultsData = (Map<String, Object>)re.get('returnResultsData');
    output.put('offers', resultsData.get('offers'));
    ```
