Server-Side API
Last updated
Was this helpful?
Last updated
Was this helpful?
The API documentation includes a . It is designed for easy browsing, allowing you to explore the functionality even without a Postman account.
If you are already using Postman, you can fork and run the collection directly in your own account.
This API uses . For the authorization, you will need to use your section's API-key.
Your authorization header should look like this:
You can request the API Key from “Settings” → “API Keys”
With the API integration, it is necessary to assign IDs to users and sessions on the customer’s side.
Creating new campaigns requires the involvement of the development team, specifically for:
Implementing a campaign request using .
Processing the received response (JSON) and rendering the result.
Passing information about a user interactions with the campaign using engagement
.
For personalization to work correctly, it is necessary to send information about page views on the website (or screen views in the application) for all the users. Typically, this task is solved together with the campaign request via a dedicated parameter in the choose request (see below). However, there is also the option to send page view information separately from the campaign request using /page endpoint.
In order to collect statistics and optimize campaigns, it is necessary to provide Gravity Field with information about user actions on the site (in the application).
Both Custom Code and Recommendations campaigns could be requested by choose
.
The campaigns are identified in the requests by API Selector Name or API Selector Groups.
To handle errors gracefully, you need to
Set a response timeout.
In case of timeout or response different from status 200, you will need either
display nothing
display a stub (default banner, pre-installed set of products in the widget, etc.). Additionally, we recommend sending a custom fallback event to Gravity Field.
In order to gather valuable statistics and further optimize your campaigns, you should pass the information about users's interactions with personalization campaigns.
All requests are limited to 500 requests per second (RPS) per section.
Keep API keys safe and do not disclose them to third parties
Ensure that all API calls for the same user within one session have the same User and Session IDs
Request recommendations asynchronously to speed up content rendering
Set a timeout for waiting for a response from the API. Prepare a default content option in advance for displaying when there is no response. It is also recommended to keep statistics on timings and cases when a response from the API was not received (additional events can be sent in case of response timeouts).
You can view all your requests and corresponding responses in real-time in your Gravity Field account (Settings/API Logs).
List of possible events: