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
To reduce the size of Digital Commerce API responses:
-
Go to the Vlocity DataRaptor tab in your org and click New.
-
In the Create Vlocity DataRaptor Interface window, enter a unique name for the DataRaptor interface, such as OffersTransformer.
-
From the Interface Type list, select Transform.
-
From the Input Type and Output Type lists, select JSON and click Save. The DataRaptor transformer is displayed on the Vlocity DataRaptor Interface page.
-
Click + to add input and output JSON paths (nodes).
-
In Input JSON Path and Output JSON Path, enter a valid JSON path from the API's response, such as
offers:offerType
. -
From the Output Data Type list, select the data type for the node, such as String.
-
Click Save and then click + to add more nodes as needed.
-
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:
-
Create a post hook for the response handler to transform responses from getOffers.
Sample post hook: