Instructions for server-side integration of the recommendation module

To receive recommendations, you need to set a special request on the backend of the product page.

The request involves receiving data in JSON format, which contains the identifier of the product for which recommendations are being displayed, and a list of these recommendations with all the parameters from the product feed.

Getting recommendations

Issuance with authorization

If you have specified in the settings that recommendations should be issued with authorization, then use:

POST enrecom.enkod.ru/recom/?id={}&scriptId={}&limit={} - get recommendations for a product by its id.

Request body:

 {
    "login": "login",
    "pass": "pass",
 }

Issuance without authorization

GET enrecom.enkod.ru/recom/?id={}&scriptId={}&limit={} - get recommendations for a product by its id.

Headers

In order for the requests to be executed correctly, you need to include the headers:

  • X-Account - system account name (ask your account-manager)
  • X-SessionGUID - session identifier

X-SessionGUID can be obtained using API-метода or using a script (the session must be read from the localstorage parameter enPop_sessionId.data and passed in this header).

Recommendations are generated for a contact's X-SessionGUID and are issued only if the contact (with this session) exists in the enKod database

Parameters

Name Type Description Mandatory
id String ID of the product for which recommendations are needed Mandatory for product-oriented algorithms
scriptId String ID of recommendation block (in the interface) Mandatory
limit String Number of products in the recommendation block Optional
login String Login for authorization Mandatory for issue with authorisation
pass String Password for authorization Mandatory for issue with authorisation

More about id parameter

Whether the parameter is mandatory depends on the algorithm used in the recommendation block. For product-oriented algorithms, passing Id is mandatory; for others, do not pass the id parameter.

Algorithms that require passing the Product Id:

  • Similar with similar text
  • Similar similar to the image
  • Related products
  • Popular products in a category

More about limit parameter

You can pass the limit parameter if you need to display fewer recommended products in a specific place than were set up in the block in the interface. If you pass a value greater than the set value in the parameter, then we will not generate recommendations that exceed the limit in the block settings.

An example of a response to a request from our service in json format:

{
    "productId": "123",
    "recom":
        [
            {
                "id": 88405,
                "information": {
                    "id":88405,
                    "title":"Lynx sleeping bag",
                    "availability":"in stock",
                    "price":"125 USD",
                    "gtin":"0191476115395",
                    "color":"white",
                    "gender":"unisex",
                    "size":"Regular Right-Handed"
                }
            },
            {
                "id": 89130,
                "information": {
                    "id":89130,
                    "title":"Lynx sleeping bag",
                    "availability":"in stock",
                    "price":"125 USD",
                    "gtin":"0191476115395",
                    "color":"white",
                    "gender":"unisex",
                    "size":"Regular Right-Handed"
                }
            }
        ]
}

Displaying recommendations on the site

After configuring the receiving of recommendations, you need to implement the output of goods on the site. To do this, you need to layout the product block according to your design and site logic. Use example_block_layout, which you can use as a basis. The example contains all the basic and mandatory attributes for correct work of the recommendations.

Click on a product in the recommendations block

POST ext.enkod.ru/recom/saveinfo

In order for the requests to run correctly, you need to specify the headers:

  • X-Account - system account name, this value will be prompted by your manager;
  • X-Session-Id - session ID

Example of a request body:

 {
    "id": "12345",
    "scriptId": "10",
 }

Request parameters:

Name Type Description Mandatory
id String Article of the product clicked on Mandatory
scriptId Int ID of recommendation block (in the interface) Mandatory
Last modified: 2024.09.02 07:59 by Elizaveta Ivannikova