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

ParameterTypeRequiredDescription
shop_idStringTrueYour 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
didStringFalseA 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
sidStringTrueA session ID is a temporary identifier assigned to the user for the current session. It must be a unique string and will be regenerated every time a new session starts. For the initial init request, do not include a sid. The sid will be generated by Kameleoon and returned in the API response. If a sid is specified in the request and it does not exist in the system, an error will occur.