Skip to main content

Initialize session

Before using any other API method in the Product Recommendation API, 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, a device identifier is missing. Call the init method without a device ID to generate one. For backend recommendation logic with Kameleoon Web Experimentation, call this API and store the IDs in the KameleoonProducts_session_code cookie for sid and KameleoonProducts_device_id for did.

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
sidStringTrue*A 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.
note

While the sid parameter is required, do not add it during the first initialization, as the system generates it and returns it in the response (as seance).

Once generated, use the system-generated sid for requests within the current session.