Skip to main content

Initialize session

Before using any other API method in the Product Recommendation API, you must call the init API. The initialization process accepts the current user identifier and requests the project settings and user preferences.

HTTP Request

GET https://api.products.kameleoon.com/init/

When to initialize

Depending on your platform, there are different requirements for when you need to run init:

  • cURL: Initialize each time the page is rendered.
  • Web: Initialize each time the page is opened (including single-page applications).
  • iOS or Android: Initialize each time the application launches.

On the first launch on a new device, you won't have a device identifier yet. Call the init method without a device ID to generate one. Store this identifier in the local storage of a mobile application or in a database as you'll need it for future requests to this API.

Query parameters

ParameterRequiredDescription
shop_idRequiredYour Store Key. You can find this in Recommendations > Settings > Store settings in the Kameleoon app. You can also contact your Customer Success Manager for the key.
didfalseA device ID. If a device ID already exists, specify it here. If you don't specify a did, the API will generate new one in the Kameleoon database. Use this generated id as the device ID for all future requests.
sidtrueA session ID. User's temporary identifier for the current session. This ID must be regenerated every time the user starts new session. Must be a unique string.

Example JSON request

{
"shop_id": "eehj3eu84299kg5ghw5a6743r8",
"did": "pmd5362597thrgq8k256ep01t0",
"sid": ["jmf1543527gykgq8k789ks99tt"]
}