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. If you have Kameleoon Web Exp and wants to implement the recommendation logic in the back-end, you will need to call this API and store the IDs in the cookies KameleoonProducts_session_code 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, you don't need to add it during the first initialization, as it is generated by the system and returned in the response (as seance).

Once it has been generated, you should use the system-generated sid for requests within the current session.