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, offers:priceResult, and offers 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

  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

  8. Click Save and then click + to add more nodes as needed.

    DataRaptor interface OffersTransformer

  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:

    Expected reduced output:

  10. Create a post hook for the response handler to transform responses from getOffers.

    Sample post hook: