Recommendations

Recommendation methods are capable of recommending items (Recommend Items to User, Recommend Items to Item) or users (Recommend Users to Item, Recommend Users to User).

See Segmentations section for recommendation endpoints that return Segments (e.g. "recommend categories to a user").

Recommendation endpoints that return the Items (content, products, etc.).

post
Allowed on Client-Side

Based on the user's past interactions (purchases, ratings, etc.) with the items, recommends top-N items that are most likely to be of high value for the given user.

The most typical use cases are recommendations on the homepage, in some "Picked just for you" section, or in email.

The returned items are sorted by relevance (the first item being the most relevant).

Besides the recommended items, also a unique recommId is returned in the response. It can be used to:

  • Let Recombee know that this recommendation was successful (e.g., user clicked one of the recommended items). See Reported metrics.
  • Get subsequent recommended items when the user scrolls down (infinite scroll) or goes to the next page. See Recommend Next Items.

It is also possible to use GET HTTP method - body parameters then become query parameters.

Copy
Initialization
const result = await client.send(new recombee.RecommendItemsToUser(userId, count, {
  // optional parameters:
  scenario: 'homepage',                                                  // string
  cascadeCreate: true,                                                   // boolean
  returnProperties: true,                                                // boolean
  includedProperties: ['title', 'price', 'publishedAt'],                 // array
  filter: 'price > 50',                                                  // string
  booster: 'if now() - \'publishedAt\' <= 7 * 24 * 3600 then 2 else 1',  // string
  logic: 'recombee:default',                                             // string / Object
  reqlExpressions: {
    isInUsersCity: 'context_user["city"] in \'cities\'',
  },                                                                     // Object
  minRelevance: 'low',                                                   // string
  rotationRate: 0.1,                                                     // number
  rotationTime: 7200.0,                                                  // number
}));

2.0.0

String
Located in: path
Required: Yes
Since version: 2.0.0

ID of your database.


String
Located in: path
Required: Yes
Since version: 2.0.0

ID of the user for whom personalized recommendations are to be generated.


Integer
Located in: body
Required: Yes
Since version: 2.0.0

Number of items to be recommended (N for the top-N recommendation).


String
Located in: body
Required: No
Since version: 2.0.0

Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing".

You can set various settings to the scenario in the Admin UI. You can also see the performance of each scenario in the Admin UI separately, so you can check how well each application performs.

The AI that optimizes models to get the best results may optimize different scenarios separately or even use different models in each of the scenarios.


Boolean
Located in: body
Required: No
Since version: 2.0.0

If the user does not exist in the database, returns a list of non-personalized recommendations and creates the user in the database. This allows, for example, rotations in the following recommendations for that user, as the user will be already known to the system.


Boolean
Located in: body
Required: No
Since version: 2.0.0

With returnProperties=true, property values of the recommended items are returned along with their IDs in a JSON dictionary. The acquired property values can be used to easily display the recommended items to the user.

Example response:

  {
    "recommId": "ce52ada4-e4d9-4885-943c-407db2dee837",
    "recomms": 
      [
        {
          "id": "tv-178",
          "values": {
            "description": "4K TV with 3D feature",
            "categories":   ["Electronics", "Televisions"],
            "price": 342,
            "url": "myshop.com/tv-178"
          }
        },
        {
          "id": "mixer-42",
          "values": {
            "description": "Stainless Steel Mixer",
            "categories":   ["Home & Kitchen"],
            "price": 39,
            "url": "myshop.com/mixer-42"
          }
        }
      ],
     "numberNextRecommsCalls": 0
  }

Array
Located in: body
Required: No
Since version: 2.0.0

Allows specifying which properties should be returned when returnProperties=true is set. The properties are given as a comma-separated list.

Example response for includedProperties=description,price:

  {
    "recommId": "a86ee8d5-cd8e-46d1-886c-8b3771d0520b",
    "recomms":
      [
        {
          "id": "tv-178",
          "values": {
            "description": "4K TV with 3D feature",
            "price": 342
          }
        },
        {
          "id": "mixer-42",
          "values": {
            "description": "Stainless Steel Mixer",
            "price": 39
          }
        }
      ],
    "numberNextRecommsCalls": 0
  }

String
Located in: body
Required: No
Since version: 2.0.0

Boolean-returning ReQL expression, which allows you to filter recommended items based on the values of their attributes.

Filters can also be assigned to a scenario in the Admin UI.


String
Located in: body
Required: No
Since version: 2.0.0

Number-returning ReQL expression, which allows you to boost the recommendation rate of some items based on the values of their attributes.

Boosters can also be assigned to a scenario in the Admin UI.


String
Object
Located in: body
Required: No
Since version: 2.4.0

Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case. See this section for a list of available logics and other details.

The difference between logic and scenario is that logic specifies mainly behavior, while scenario specifies the place where recommendations are shown to the users.

Logic can also be set to a scenario in the Admin UI.


Object
Located in: body
Required: No
Since version: 6.0.0

A dictionary of ReQL expressions that will be executed for each recommended item. This can be used to compute additional properties of the recommended items that are not stored in the database.

The keys are the names of the expressions, and the values are the actual ReQL expressions.

Example request:

{
  "reqlExpressions": {
    "isInUsersCity": "context_user[\"city\"] in 'cities'",
    "distanceToUser": "earth_distance('location', context_user[\"location\"])"
  }
}

Example response:

{
  "recommId": "ce52ada4-e4d9-4885-943c-407db2dee837",
  "recomms": 
    [
      {
        "id": "restaurant-178",
        "reqlEvaluations": {
          "isInUsersCity": true,
          "distanceToUser": 5200.2
        }
      },
      {
        "id": "bar-42",
        "reqlEvaluations": {
          "isInUsersCity": false,
          "distanceToUser": 2516.0
        }
      }
    ],
   "numberNextRecommsCalls": 0
}

String
Located in: body
Required: No
Since version: 2.0.0

Expert option: Specifies the threshold of how relevant must the recommended items be to the user. Possible values one of: "low", "medium", "high". The default value is "low", meaning that the system attempts to recommend a number of items equal to count at any cost. If there is not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations to be appended to reach the full count. This behavior may be suppressed by using "medium" or "high" values. In such a case, the system only recommends items of at least the requested relevance and may return less than count items when there is not enough data to fulfill it.


Number
Located in: body
Required: No
Since version: 2.0.0

Expert option: If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per request in a backward fashion. You may penalize an item for being recommended in the near past. For the specific user, rotationRate=1 means maximal rotation, rotationRate=0 means absolutely no rotation. You may also use, for example, rotationRate=0.2 for only slight rotation of recommended items. Default: 0.


Number
Located in: body
Required: No
Since version: 2.0.0

Expert option: Taking rotationRate into account, specifies how long it takes for an item to recover from the penalization. For example, rotationTime=7200.0 means that items recommended less than 2 hours ago are penalized. Default: 7200.0.


Successful operation.

{
  "recommId": "3f6ad2f2-a3f1-4ba1-a690-f4f01f76d4eb",
  "recomms": [
    {
      "id": "item-146"
    },
    {
      "id": "item-462"
    },
    {
      "id": "item-463"
    }
  ],
  "numberNextRecommsCalls": 0
}

userId does not match ^[a-zA-Z0-9_-:@.]+$, count is not a positive integer, filter or booster is not valid ReQL expressions, filter expression does not return boolean, booster does not return double or integer.


userId not found in the database and cascadeCreate is false. If there is no additional info in the JSON response, you probably have an error in your URL.


post
Allowed on Client-Side

Recommends a set of items that are somehow related to one given item, X. A typical scenario is when the user A is viewing X. Then you may display items to the user that he might also be interested in. Recommend items to item request gives you Top-N such items, optionally taking the target user A into account.

The returned items are sorted by relevance (the first item being the most relevant).

Besides the recommended items, also a unique recommId is returned in the response. It can be used to:

  • Let Recombee know that this recommendation was successful (e.g., user clicked one of the recommended items). See Reported metrics.
  • Get subsequent recommended items when the user scrolls down (infinite scroll) or goes to the next page. See Recommend Next Items.

It is also possible to use GET HTTP method - body parameters then become query parameters.

Copy
Initialization
const result = await client.send(new recombee.RecommendItemsToItem(itemId, targetUserId, count, {
  // optional parameters:
  scenario: 'homepage',                                                  // string
  cascadeCreate: true,                                                   // boolean
  returnProperties: true,                                                // boolean
  includedProperties: ['title', 'price', 'publishedAt'],                 // array
  filter: 'price > 50',                                                  // string
  booster: 'if now() - \'publishedAt\' <= 7 * 24 * 3600 then 2 else 1',  // string
  logic: 'recombee:default',                                             // string / Object
  reqlExpressions: {
    isInUsersCity: 'context_user["city"] in \'cities\'',
  },                                                                     // Object
  minRelevance: 'low',                                                   // string
  rotationRate: 0.1,                                                     // number
  rotationTime: 7200.0,                                                  // number
}));

2.0.0

String
Located in: path
Required: Yes
Since version: 2.0.0

ID of your database.


String
Located in: path
Required: Yes
Since version: 2.0.0

ID of the item for which the recommendations are to be generated.


String
Located in: body
Required: Yes
Since version: 2.0.0

ID of the user who will see the recommendations.

Specifying the targetUserId is beneficial because:

  • It makes the recommendations personalized
  • Allows the calculation of Actions and Conversions in the graphical user interface, as Recombee can pair the user who got recommendations and who afterward viewed/purchased an item.

If you insist on not specifying the user, pass null (None, nil, NULL etc., depending on the language) to targetUserId. Do not create some special dummy user for getting recommendations, as it could mislead the recommendation models, and result in wrong recommendations.

For anonymous/unregistered users, it is possible to use, for example, their session ID.


Integer
Located in: body
Required: Yes
Since version: 2.0.0

Number of items to be recommended (N for the top-N recommendation).


String
Located in: body
Required: No
Since version: 2.0.0

Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing".

You can set various settings to the scenario in the Admin UI. You can also see the performance of each scenario in the Admin UI separately, so you can check how well each application performs.

The AI that optimizes models to get the best results may optimize different scenarios separately or even use different models in each of the scenarios.


Boolean
Located in: body
Required: No
Since version: 2.0.0

If an item of the given itemId or user of the given targetUserId doesn't exist in the database, it creates the missing entity/entities and returns some (non-personalized) recommendations. This allows, for example, rotations in the following recommendations for the user of the given targetUserId, as the user will be already known to the system.


Boolean
Located in: body
Required: No
Since version: 2.0.0

With returnProperties=true, property values of the recommended items are returned along with their IDs in a JSON dictionary. The acquired property values can be used to easily display the recommended items to the user.

Example response:

  {
    "recommId": "0c6189e7-dc1a-429a-b613-192696309361",
    "recomms":
      [
        {
          "id": "tv-178",
          "values": {
            "description": "4K TV with 3D feature",
            "categories":   ["Electronics", "Televisions"],
            "price": 342,
            "url": "myshop.com/tv-178"
          }
        },
        {
          "id": "mixer-42",
          "values": {
            "description": "Stainless Steel Mixer",
            "categories":   ["Home & Kitchen"],
            "price": 39,
            "url": "myshop.com/mixer-42"
          }
        }
      ],
    "numberNextRecommsCalls": 0
  }

Array
Located in: body
Required: No
Since version: 2.0.0

Allows specifying which properties should be returned when returnProperties=true is set. The properties are given as a comma-separated list.

Example response for includedProperties=description,price:

  {
    "recommId": "6842c725-a79f-4537-a02c-f34d668a3f80",
    "recomms":
      [
        {
          "id": "tv-178",
          "values": {
            "description": "4K TV with 3D feature",
            "price": 342
          }
        },
        {
          "id": "mixer-42",
          "values": {
            "description": "Stainless Steel Mixer",
            "price": 39
          }
        }
      ],
    "numberNextRecommsCalls": 0
  }

String
Located in: body
Required: No
Since version: 2.0.0

Boolean-returning ReQL expression, which allows you to filter recommended items based on the values of their attributes.

Filters can also be assigned to a scenario in the Admin UI.


String
Located in: body
Required: No
Since version: 2.0.0

Number-returning ReQL expression, which allows you to boost the recommendation rate of some items based on the values of their attributes.

Boosters can also be assigned to a scenario in the Admin UI.


String
Object
Located in: body
Required: No
Since version: 2.4.0

Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case. See this section for a list of available logics and other details.

The difference between logic and scenario is that logic specifies mainly behavior, while scenario specifies the place where recommendations are shown to the users.

Logic can also be set to a scenario in the Admin UI.


Object
Located in: body
Required: No
Since version: 6.0.0

A dictionary of ReQL expressions that will be executed for each recommended item. This can be used to compute additional properties of the recommended items that are not stored in the database.

The keys are the names of the expressions, and the values are the actual ReQL expressions.

Example request:

{
  "reqlExpressions": {
    "isInUsersCity": "context_user[\"city\"] in 'cities'",
    "distanceToUser": "earth_distance('location', context_user[\"location\"])",
    "isFromSameCompany": "'company' == context_item[\"company\"]"
  }
}

Example response:

{
  "recommId": "ce52ada4-e4d9-4885-943c-407db2dee837",
  "recomms": 
    [
      {
        "id": "restaurant-178",
        "reqlEvaluations": {
          "isInUsersCity": true,
          "distanceToUser": 5200.2,
          "isFromSameCompany": false
        }
      },
      {
        "id": "bar-42",
        "reqlEvaluations": {
          "isInUsersCity": false,
          "distanceToUser": 2516.0,
          "isFromSameCompany": true
        }
      }
    ],
   "numberNextRecommsCalls": 0
}

String
Located in: body
Required: No
Since version: 2.0.0

Expert option: If the targetUserId is provided: Specifies the threshold of how relevant must the recommended items be to the user. Possible values one of: "low", "medium", "high". The default value is "low", meaning that the system attempts to recommend a number of items equal to count at any cost. If there is not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations being appended to reach the full count. This behavior may be suppressed by using "medium" or "high" values. In such case, the system only recommends items of at least the requested relevance and may return less than count items when there is not enough data to fulfill it.


Number
Located in: body
Required: No
Since version: 2.0.0

Expert option: If the targetUserId is provided: If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per request in a backward fashion. You may penalize an item for being recommended in the near past. For the specific user, rotationRate=1 means maximal rotation, rotationRate=0 means absolutely no rotation. You may also use, for example, rotationRate=0.2 for only slight rotation of recommended items.


Number
Located in: body
Required: No
Since version: 2.0.0

Expert option: If the targetUserId is provided: Taking rotationRate into account, specifies how long it takes for an item to recover from the penalization. For example, rotationTime=7200.0 means that items recommended less than 2 hours ago are penalized.


Successful operation.

{
  "recommId": "768448ea-10b3-4028-bb76-4b2f95121d19",
  "recomms": [
    {
      "id": "item-146"
    },
    {
      "id": "item-462"
    },
    {
      "id": "item-463"
    }
  ],
  "numberNextRecommsCalls": 0
}

itemId does not match ^[a-zA-Z0-9_-:@.]+$, count is not a positive integer, filter or booster is not valid ReQL expressions, filter expression does not return boolean, booster does not return double or integer.


itemId not found in the database and cascadeCreate is false. If there is no additional info in the JSON response, you probably have an error in your URL.


post
Allowed on Client-Side

Recommends Items that are the most relevant to a particular Segment from a context Segmentation.

Based on the used Segmentation, this endpoint can be used for example for:

  • Recommending articles related to a particular topic
  • Recommending songs belonging to a particular genre
  • Recommending products produced by a particular brand

You need to set the used context Segmentation in the Admin UI in the Scenario settings prior to using this endpoint.

The returned items are sorted by relevance (the first item being the most relevant).

It is also possible to use GET HTTP method - body parameters then become query parameters.

Copy
Initialization
const result = await client.send(new recombee.RecommendItemsToItemSegment(contextSegmentId, targetUserId, count, {
  // optional parameters:
  scenario: 'homepage',                                                  // string
  cascadeCreate: true,                                                   // boolean
  returnProperties: true,                                                // boolean
  includedProperties: ['title', 'price', 'publishedAt'],                 // array
  filter: 'price > 50',                                                  // string
  booster: 'if now() - \'publishedAt\' <= 7 * 24 * 3600 then 2 else 1',  // string
  logic: 'recombee:personal-from-segment',                               // string / Object
  reqlExpressions: {
    isInUsersCity: 'context_user["city"] in \'cities\'',
  },                                                                     // Object
  minRelevance: 'low',                                                   // string
  rotationRate: 0.1,                                                     // number
  rotationTime: 7200.0,                                                  // number
}));

5.0.0

String
Located in: path
Required: Yes
Since version: 5.0.0

ID of your database.


String
Located in: body
Required: Yes
Since version: 5.0.0

ID of the segment from contextSegmentationId for which the recommendations are to be generated.


String
Located in: body
Required: Yes
Since version: 5.0.0

ID of the user who will see the recommendations.

Specifying the targetUserId is beneficial because:

  • It makes the recommendations personalized
  • Allows the calculation of Actions and Conversions in the graphical user interface, as Recombee can pair the user who got recommendations and who afterward viewed/purchased an item.

If you insist on not specifying the user, pass null (None, nil, NULL etc., depending on the language) to targetUserId. Do not create some special dummy user for getting recommendations, as it could mislead the recommendation models, and result in wrong recommendations.

For anonymous/unregistered users, it is possible to use, for example, their session ID.


Integer
Located in: body
Required: Yes
Since version: 5.0.0

Number of items to be recommended (N for the top-N recommendation).


String
Located in: body
Required: No
Since version: 5.0.0

Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing".

You can set various settings to the scenario in the Admin UI. You can also see the performance of each scenario in the Admin UI separately, so you can check how well each application performs.

The AI that optimizes models to get the best results may optimize different scenarios separately or even use different models in each of the scenarios.


Boolean
Located in: body
Required: No
Since version: 5.0.0

If a user of the given targetUserId doesn't exist in the database, it creates this user and returns some (non-personalized) recommendations. This allows, for example, rotations in the following recommendations for the user of the given targetUserId, as the user will be already known to the system.


Boolean
Located in: body
Required: No
Since version: 5.0.0

With returnProperties=true, property values of the recommended items are returned along with their IDs in a JSON dictionary. The acquired property values can be used to easily display the recommended items to the user.

Example response:

  {
    "recommId": "0c6189e7-dc1a-429a-b613-192696309361",
    "recomms":
      [
        {
          "id": "tv-178",
          "values": {
            "description": "4K TV with 3D feature",
            "categories":   ["Electronics", "Televisions"],
            "price": 342,
            "url": "myshop.com/tv-178"
          }
        },
        {
          "id": "mixer-42",
          "values": {
            "description": "Stainless Steel Mixer",
            "categories":   ["Home & Kitchen"],
            "price": 39,
            "url": "myshop.com/mixer-42"
          }
        }
      ],
    "numberNextRecommsCalls": 0
  }

Array
Located in: body
Required: No
Since version: 5.0.0

Allows specifying which properties should be returned when returnProperties=true is set. The properties are given as a comma-separated list.

Example response for includedProperties=description,price:

  {
    "recommId": "6842c725-a79f-4537-a02c-f34d668a3f80",
    "recomms":
      [
        {
          "id": "tv-178",
          "values": {
            "description": "4K TV with 3D feature",
            "price": 342
          }
        },
        {
          "id": "mixer-42",
          "values": {
            "description": "Stainless Steel Mixer",
            "price": 39
          }
        }
      ],
    "numberNextRecommsCalls": 0
  }

String
Located in: body
Required: No
Since version: 5.0.0

Boolean-returning ReQL expression, which allows you to filter recommended items based on the values of their attributes.

Filters can also be assigned to a scenario in the Admin UI.


String
Located in: body
Required: No
Since version: 5.0.0

Number-returning ReQL expression, which allows you to boost the recommendation rate of some items based on the values of their attributes.

Boosters can also be assigned to a scenario in the Admin UI.


String
Object
Located in: body
Required: No
Since version: 5.0.0

Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case. See this section for a list of available logics and other details.

The difference between logic and scenario is that logic specifies mainly behavior, while scenario specifies the place where recommendations are shown to the users.

Logic can also be set to a scenario in the Admin UI.


Object
Located in: body
Required: No
Since version: 6.0.0

A dictionary of ReQL expressions that will be executed for each recommended item. This can be used to compute additional properties of the recommended items that are not stored in the database.

The keys are the names of the expressions, and the values are the actual ReQL expressions.

Example request:

{
  "reqlExpressions": {
    "isInUsersCity": "context_user[\"city\"] in 'cities'",
    "distanceToUser": "earth_distance('location', context_user[\"location\"])"
  }
}

Example response:

{
  "recommId": "ce52ada4-e4d9-4885-943c-407db2dee837",
  "recomms": 
    [
      {
        "id": "restaurant-178",
        "reqlEvaluations": {
          "isInUsersCity": true,
          "distanceToUser": 5200.2
        }
      },
      {
        "id": "bar-42",
        "reqlEvaluations": {
          "isInUsersCity": false,
          "distanceToUser": 2516.0
        }
      }
    ],
   "numberNextRecommsCalls": 0
}

String
Located in: body
Required: No
Since version: 5.0.0

Expert option: If the targetUserId is provided: Specifies the threshold of how relevant must the recommended items be to the user. Possible values one of: "low", "medium", "high". The default value is "low", meaning that the system attempts to recommend a number of items equal to count at any cost. If there is not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations being appended to reach the full count. This behavior may be suppressed by using "medium" or "high" values. In such case, the system only recommends items of at least the requested relevance and may return less than count items when there is not enough data to fulfill it.


Number
Located in: body
Required: No
Since version: 5.0.0

Expert option: If the targetUserId is provided: If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per request in a backward fashion. You may penalize an item for being recommended in the near past. For the specific user, rotationRate=1 means maximal rotation, rotationRate=0 means absolutely no rotation. You may also use, for example, rotationRate=0.2 for only slight rotation of recommended items.


Number
Located in: body
Required: No
Since version: 5.0.0

Expert option: If the targetUserId is provided: Taking rotationRate into account, specifies how long it takes for an item to recover from the penalization. For example, rotationTime=7200.0 means that items recommended less than 2 hours ago are penalized.


successful operation

{
  "recommId": "768448ea-10b3-4028-bb76-4b2f95121d19",
  "recomms": [
    {
      "id": "item-176"
    },
    {
      "id": "item-141"
    },
    {
      "id": "item-967"
    }
  ],
  "numberNextRecommsCalls": 0
}

count is not a positive integer.


contextSegmentId not found in the context segmentation


post
Allowed on Client-Side

Returns items that shall be shown to a user as next recommendations when the user e.g. scrolls the page down (infinite scroll) or goes to the next page.

It accepts recommId of a base recommendation request (e.g., request from the first page) and the number of items that shall be returned (count). The base request can be one of:

All the other parameters are inherited from the base request.

Recommend next items can be called many times for a single recommId and each call returns different (previously not recommended) items. The number of Recommend next items calls performed so far is returned in the numberNextRecommsCalls field.

Recommend next items can be requested up to 30 minutes after the base request or a previous Recommend next items call.

For billing purposes, each call to Recommend next items is counted as a separate recommendation request.

It is also possible to use GET HTTP method - body parameters then become query parameters.

Copy
Initialization
const result = await client.send(new recombee.RecommendNextItems(recommId, count));

3.1.0

String
Located in: path
Required: Yes
Since version: 3.1.0

ID of your database.


String
Located in: path
Required: Yes
Since version: 3.1.0

ID of the base recommendation request for which next recommendations should be returned


Integer
Located in: body
Required: Yes
Since version: 3.1.0

Number of items to be recommended


Successful operation.

{
  "recommId": "768448ea-10b3-4028-bb76-4b2f95121d19",
  "recomms": [
    {
      "id": "item-176"
    },
    {
      "id": "item-141"
    },
    {
      "id": "item-967"
    }
  ],
  "numberNextRecommsCalls": 4
}

Parameter count is not given or is not a positive integer. Parameter recommId is not an UUID.


Base request with the given recommId does not exist or has expired.


Recommendation endpoints that return the Item Segments (categories, genres, artists, etc.).

post
Allowed on Client-Side

Recommends the top Segments from a Segmentation for a particular user, based on the user's past interactions.

Based on the used Segmentation, this endpoint can be used for example for:

  • Recommending the top categories for the user
  • Recommending the top genres for the user
  • Recommending the top brands for the user
  • Recommending the top artists for the user

You need to set the used Segmentation the Admin UI in the Scenario settings prior to using this endpoint.

The returned segments are sorted by relevance (first segment being the most relevant).

It is also possible to use GET HTTP method - body parameters then become query parameters.

Copy
Initialization
const result = await client.send(new recombee.RecommendItemSegmentsToUser(userId, count, {
  // optional parameters:
  scenario: 'homepage',                                              // string
  cascadeCreate: true,                                               // boolean
  filter: '\'segmentId\' != "coupons"',                              // string
  booster: 'if \'segmentId\' == "Editors Pick" then 2 else 1',       // string
  logic: 'recombee:default',                                         // string / Object
  reqlExpressions: {
    countItems: 'size(segment_items("categories", \'segmentId\'))',
  },                                                                 // Object
}));

4.1.0

String
Located in: path
Required: Yes
Since version: 4.1.0

ID of your database.


String
Located in: path
Required: Yes
Since version: 4.1.0

ID of the user for whom personalized recommendations are to be generated.


Integer
Located in: body
Required: Yes
Since version: 4.1.0

Number of item segments to be recommended (N for the top-N recommendation).


String
Located in: body
Required: No
Since version: 4.1.0

Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing".

You can set various settings to the scenario in the Admin UI. You can also see the performance of each scenario in the Admin UI separately, so you can check how well each application performs.

The AI that optimizes models to get the best results may optimize different scenarios separately or even use different models in each of the scenarios.


Boolean
Located in: body
Required: No
Since version: 4.1.0

If the user does not exist in the database, returns a list of non-personalized recommendations and creates the user in the database. This allows, for example, rotations in the following recommendations for that user, as the user will be already known to the system.


String
Located in: body
Required: No
Since version: 4.1.0

Boolean-returning ReQL expression which allows you to filter recommended segments based on the segmentationId.


String
Located in: body
Required: No
Since version: 4.1.0

Number-returning ReQL expression which allows you to boost recommendation rate of some segments based on the segmentationId.


String
Object
Located in: body
Required: No
Since version: 4.1.0

Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case. See this section for a list of available logics and other details.

The difference between logic and scenario is that logic specifies mainly behavior, while scenario specifies the place where recommendations are shown to the users.

Logic can also be set to a scenario in the Admin UI.


Object
Located in: body
Required: No
Since version: 6.1.0

A dictionary of ReQL expressions that will be executed for each recommended Item Segment. This can be used to compute additional properties of the recommended Item Segments.

The keys are the names of the expressions, and the values are the actual ReQL expressions.

Example request:

{
  "reqlExpressions": {
    "countItems": "size(segment_items(\"categories\", 'segmentId'))"
  }
}

Example response:

{
  "recommId": "a7ac55a4-8d6e-4f19-addc-abac4164d8a8",
  "recomms": 
    [
      {
        "id": "category-fantasy-books",
        "reqlEvaluations": {
          "countItems": 486
        }
      },
      {
        "id": "category-sci-fi-costumes",
        "reqlEvaluations": {
          "countItems": 19
        }
      }
    ],
   "numberNextRecommsCalls": 0
}

successful operation

{
  "recommId": "5fbd94fa-2553-422c-bdb5-af82687d8c6a",
  "recomms": [
    {
      "id": "category-rap"
    },
    {
      "id": "category-dnb"
    },
    {
      "id": "category-electronic"
    }
  ],
  "numberNextRecommsCalls": 0
}

Used Segmentation not configured for the scenario. userId does not match ^[a-zA-Z0-9_-:@.]+$, count is not a positive integer.


userId not found in the database and cascadeCreate is false


post
Allowed on Client-Side

Recommends Segments from a Segmentation that are the most relevant to a particular item.

Based on the used Segmentation, this endpoint can be used for example for:

  • Recommending the related categories
  • Recommending the related genres
  • Recommending the related brands
  • Recommending the related artists

You need to set the used Segmentation the Admin UI in the Scenario settings prior to using this endpoint.

The returned segments are sorted by relevance (first segment being the most relevant).

It is also possible to use GET HTTP method - body parameters then become query parameters.

Copy
Initialization
const result = await client.send(new recombee.RecommendItemSegmentsToItem(itemId, targetUserId, count, {
  // optional parameters:
  scenario: 'homepage',                                              // string
  cascadeCreate: true,                                               // boolean
  filter: '\'segmentId\' != "coupons"',                              // string
  booster: 'if \'segmentId\' == "Editors Pick" then 2 else 1',       // string
  logic: 'recombee:default',                                         // string / Object
  reqlExpressions: {
    countItems: 'size(segment_items("categories", \'segmentId\'))',
  },                                                                 // Object
}));

4.1.0

String
Located in: path
Required: Yes
Since version: 4.1.0

ID of your database.


String
Located in: path
Required: Yes
Since version: 4.1.0

ID of the item for which the recommendations are to be generated.


String
Located in: body
Required: Yes
Since version: 4.1.0

ID of the user who will see the recommendations.

Specifying the targetUserId is beneficial because:

  • It makes the recommendations personalized
  • Allows the calculation of Actions and Conversions in the graphical user interface, as Recombee can pair the user who got recommendations and who afterward viewed/purchased an item.

If you insist on not specifying the user, pass null (None, nil, NULL etc., depending on the language) to targetUserId. Do not create some special dummy user for getting recommendations, as it could mislead the recommendation models, and result in wrong recommendations.

For anonymous/unregistered users, it is possible to use, for example, their session ID.


Integer
Located in: body
Required: Yes
Since version: 4.1.0

Number of item segments to be recommended (N for the top-N recommendation).


String
Located in: body
Required: No
Since version: 4.1.0

Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing".

You can set various settings to the scenario in the Admin UI. You can also see the performance of each scenario in the Admin UI separately, so you can check how well each application performs.

The AI that optimizes models to get the best results may optimize different scenarios separately or even use different models in each of the scenarios.


Boolean
Located in: body
Required: No
Since version: 4.1.0

If the user does not exist in the database, returns a list of non-personalized recommendations and creates the user in the database. This allows, for example, rotations in the following recommendations for that user, as the user will be already known to the system.


String
Located in: body
Required: No
Since version: 4.1.0

Boolean-returning ReQL expression which allows you to filter recommended segments based on the segmentationId.


String
Located in: body
Required: No
Since version: 4.1.0

Number-returning ReQL expression which allows you to boost recommendation rate of some segments based on the segmentationId.


String
Object
Located in: body
Required: No
Since version: 4.1.0

Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case. See this section for a list of available logics and other details.

The difference between logic and scenario is that logic specifies mainly behavior, while scenario specifies the place where recommendations are shown to the users.

Logic can also be set to a scenario in the Admin UI.


Object
Located in: body
Required: No
Since version: 6.1.0

A dictionary of ReQL expressions that will be executed for each recommended Item Segment. This can be used to compute additional properties of the recommended Item Segments.

The keys are the names of the expressions, and the values are the actual ReQL expressions.

Example request:

{
  "reqlExpressions": {
    "countItems": "size(segment_items(\"categories\", 'segmentId'))"
  }
}

Example response:

{
  "recommId": "a7ac55a4-8d6e-4f19-addc-abac4164d8a8",
  "recomms": 
    [
      {
        "id": "category-fantasy-books",
        "reqlEvaluations": {
          "countItems": 486
        }
      },
      {
        "id": "category-sci-fi-costumes",
        "reqlEvaluations": {
          "countItems": 19
        }
      }
    ],
   "numberNextRecommsCalls": 0
}

successful operation

{
  "recommId": "5fbd94fa-2553-422c-bdb5-af82687d8c6a",
  "recomms": [
    {
      "id": "category-rap"
    },
    {
      "id": "category-dnb"
    },
    {
      "id": "category-electronic"
    }
  ],
  "numberNextRecommsCalls": 0
}

Used Segmentation not configured for the scenario. itemId does not match ^[a-zA-Z0-9_-:@.]+$, count is not a positive integer.


itemId not found in the database and cascadeCreate is false


post
Allowed on Client-Side

Recommends Segments from a result Segmentation that are the most relevant to a particular Segment from a context Segmentation.

Based on the used Segmentations, this endpoint can be used for example for:

  • Recommending the related brands to particular brand
  • Recommending the related brands to particular category
  • Recommending the related artists to a particular genre (assuming songs are the Items)

You need to set the used context and result Segmentation the Admin UI in the Scenario settings prior to using this endpoint.

The returned segments are sorted by relevance (first segment being the most relevant).

It is also possible to use GET HTTP method - body parameters then become query parameters.

Copy
Initialization
const result = await client.send(new recombee.RecommendItemSegmentsToItemSegment(contextSegmentId, targetUserId, count, {
  // optional parameters:
  scenario: 'homepage',                                              // string
  cascadeCreate: true,                                               // boolean
  filter: '\'segmentId\' != "coupons"',                              // string
  booster: 'if \'segmentId\' == "Editors Pick" then 2 else 1',       // string
  logic: 'recombee:default',                                         // string / Object
  reqlExpressions: {
    countItems: 'size(segment_items("categories", \'segmentId\'))',
  },                                                                 // Object
}));

4.1.0

String
Located in: path
Required: Yes
Since version: 4.1.0

ID of your database.


String
Located in: body
Required: Yes
Since version: 4.1.0

ID of the segment from contextSegmentationId for which the recommendations are to be generated.


String
Located in: body
Required: Yes
Since version: 4.1.0

ID of the user who will see the recommendations.

Specifying the targetUserId is beneficial because:

  • It makes the recommendations personalized
  • Allows the calculation of Actions and Conversions in the graphical user interface, as Recombee can pair the user who got recommendations and who afterward viewed/purchased an item.

If you insist on not specifying the user, pass null (None, nil, NULL etc., depending on the language) to targetUserId. Do not create some special dummy user for getting recommendations, as it could mislead the recommendation models, and result in wrong recommendations.

For anonymous/unregistered users, it is possible to use, for example, their session ID.


Integer
Located in: body
Required: Yes
Since version: 4.1.0

Number of item segments to be recommended (N for the top-N recommendation).


String
Located in: body
Required: No
Since version: 4.1.0

Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing".

You can set various settings to the scenario in the Admin UI. You can also see the performance of each scenario in the Admin UI separately, so you can check how well each application performs.

The AI that optimizes models to get the best results may optimize different scenarios separately or even use different models in each of the scenarios.


Boolean
Located in: body
Required: No
Since version: 4.1.0

If the user does not exist in the database, returns a list of non-personalized recommendations and creates the user in the database. This allows, for example, rotations in the following recommendations for that user, as the user will be already known to the system.


String
Located in: body
Required: No
Since version: 4.1.0

Boolean-returning ReQL expression which allows you to filter recommended segments based on the segmentationId.


String
Located in: body
Required: No
Since version: 4.1.0

Number-returning ReQL expression which allows you to boost recommendation rate of some segments based on the segmentationId.


String
Object
Located in: body
Required: No
Since version: 4.1.0

Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case. See this section for a list of available logics and other details.

The difference between logic and scenario is that logic specifies mainly behavior, while scenario specifies the place where recommendations are shown to the users.

Logic can also be set to a scenario in the Admin UI.


Object
Located in: body
Required: No
Since version: 6.1.0

A dictionary of ReQL expressions that will be executed for each recommended Item Segment. This can be used to compute additional properties of the recommended Item Segments.

The keys are the names of the expressions, and the values are the actual ReQL expressions.

Example request:

{
  "reqlExpressions": {
    "countItems": "size(segment_items(\"categories\", 'segmentId'))"
  }
}

Example response:

{
  "recommId": "a7ac55a4-8d6e-4f19-addc-abac4164d8a8",
  "recomms": 
    [
      {
        "id": "category-fantasy-books",
        "reqlEvaluations": {
          "countItems": 486
        }
      },
      {
        "id": "category-sci-fi-costumes",
        "reqlEvaluations": {
          "countItems": 19
        }
      }
    ],
   "numberNextRecommsCalls": 0
}

successful operation

{
  "recommId": "5fbd94fa-2553-422c-bdb5-af82687d8c6a",
  "recomms": [
    {
      "id": "category-rap"
    },
    {
      "id": "category-dnb"
    },
    {
      "id": "category-electronic"
    }
  ],
  "numberNextRecommsCalls": 0
}

count is not a positive integer.


contextSegmentId not found in the context segmentation


post
Allowed on Client-Side

Returns Item Segments to be shown as the next recommendations when a user scrolls (e.g., within a carousel or feed of Item Segments such as brands, artists, topics, or categories).

The request requires the recommId of a base recommendation request and the number of Segments to return (count).

The base request can be one of:

All other parameters are inherited from the base request associated with the provided recommId.

This endpoint can be called multiple times for a single recommId. Each call returns different Item Segments that have not been recommended in previous calls. The number of calls made so far is returned in the numberNextRecommsCalls field.

Requests can be made up to 30 minutes after the base request or the most recent Recommend Next Item Segments call.

For billing purposes, each call to this endpoint is counted as a separate recommendation request.

It is also possible to use GET HTTP method - body parameters then become query parameters.

Copy
Initialization
const result = await client.send(new recombee.RecommendNextItemSegments(recommId, count));

6.2.0

String
Located in: path
Required: Yes
Since version: 6.2.0

ID of your database.


String
Located in: path
Required: Yes
Since version: 6.2.0

ID of the base recommendation request for which next recommendations should be returned


Integer
Located in: body
Required: Yes
Since version: 6.2.0

Number of item segments to be recommended


Successful operation.

{
  "recommId": "768448ea-10b3-4028-bb76-4b2f95121d19",
  "recomms": [
    {
      "id": "Comedy"
    },
    {
      "id": "Drama"
    },
    {
      "id": "Action"
    }
  ],
  "numberNextRecommsCalls": 4
}

Parameter count is not given or is not a positive integer. Parameter recommId is not an UUID.


Base request with the given recommId does not exist or has expired.


Recommendation endpoints that return the Users.

post

Gets users similar to the given user, based on the user's past interactions (purchases, ratings, etc.) and values of properties.

It is also possible to use GET HTTP method - body parameters then become query parameters.

The returned users are sorted by similarity (the first user being the most similar).

Copy
Initialization
const result = await client.send(new requests.RecommendUsersToUser(userId, count, {
  // optional parameters:
  scenario: 'homepage',                                                // string
  cascadeCreate: true,                                                 // boolean
  returnProperties: true,                                              // boolean
  includedProperties: ['username', 'country'],                         // array
  filter: '\'country\' == "US"',                                       // string
  booster: 'if \'country\' == context_user["country"] then 2 else 1',  // string
  logic: 'recombee:default',                                           // string / Object
  reqlExpressions: {
    isInUsersCity: 'context_user["city"] in \'cities\'',
  },                                                                   // Object
  rotationRate: 0.1,                                                   // number
  rotationTime: 7200.0,                                                // number
}));

2.0.0

String
Located in: path
Required: Yes
Since version: 2.0.0

ID of your database.


String
Located in: path
Required: Yes
Since version: 2.0.0

User to whom we find similar users


Integer
Located in: body
Required: Yes
Since version: 2.0.0

Number of users to be recommended (N for the top-N recommendation).


String
Located in: body
Required: No
Since version: 2.0.0

Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing".

You can set various settings to the scenario in the Admin UI. You can also see the performance of each scenario in the Admin UI separately, so you can check how well each application performs.

The AI that optimizes models to get the best results may optimize different scenarios separately or even use different models in each of the scenarios.


Boolean
Located in: body
Required: No
Since version: 2.0.0

If the user does not exist in the database, returns a list of non-personalized recommendations and creates the user in the database. This allows, for example, rotations in the following recommendations for that user, as the user will be already known to the system.


Boolean
Located in: body
Required: No
Since version: 2.0.0

With returnProperties=true, property values of the recommended users are returned along with their IDs in a JSON dictionary. The acquired property values can be used to easily display the recommended users.

Example response:

  {
    "recommId": "9cb9c55d-50ba-4478-84fd-ab456136156e",
    "recomms":
      [
        {
          "id": "user-17",
          "values": {
            "country": "US",
            "sex": "F"
          }
        },
        {
          "id": "user-2",
          "values": {
            "country": "CAN",
            "sex": "M"
          }
        }
      ],
    "numberNextRecommsCalls": 0
  }

Array
Located in: body
Required: No
Since version: 2.0.0

Allows specifying which properties should be returned when returnProperties=true is set. The properties are given as a comma-separated list.

Example response for includedProperties=country:

  {
    "recommId": "b326d82d-5d57-4b45-b362-c9d6f0895855",
    "recomms":
      [
        {
          "id": "user-17",
          "values": {
            "country": "US"
          }
        },
        {
          "id": "user-2",
          "values": {
            "country": "CAN"
          }
        }
      ],
    "numberNextRecommsCalls": 0
  }

String
Located in: body
Required: No
Since version: 2.0.0

Boolean-returning ReQL expression, which allows you to filter recommended users based on the values of their attributes.

Filters can also be assigned to a scenario in the Admin UI.


String
Located in: body
Required: No
Since version: 2.0.0

Number-returning ReQL expression, which allows you to boost the recommendation rate of some users based on the values of their attributes.

Boosters can also be assigned to a scenario in the Admin UI.


String
Object
Located in: body
Required: No
Since version: 2.4.0

Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case. See this section for a list of available logics and other details.

The difference between logic and scenario is that logic specifies mainly behavior, while scenario specifies the place where recommendations are shown to the users.

Logic can also be set to a scenario in the Admin UI.


Object
Located in: body
Required: No
Since version: 6.0.0

A dictionary of ReQL expressions that will be executed for each recommended user. This can be used to compute additional properties of the recommended users that are not stored in the database.

The keys are the names of the expressions, and the values are the actual ReQL expressions.

Example request:

{
  "reqlExpressions": {
    "isInUsersCity": "context_user[\"city\"] in 'cities'",
    "distanceToUser": "earth_distance('location', context_user[\"location\"])"
  }
}

Example response:

{
  "recommId": "ce52ada4-e4d9-4885-943c-407db2dee837",
  "recomms": 
    [
      {
        "id": "restaurant-178",
        "reqlEvaluations": {
          "isInUsersCity": true,
          "distanceToUser": 5200.2
        }
      },
      {
        "id": "bar-42",
        "reqlEvaluations": {
          "isInUsersCity": false,
          "distanceToUser": 2516.0
        }
      }
    ],
   "numberNextRecommsCalls": 0
}

Number
Located in: body
Required: No
Since version: 5.0.0

Expert option: If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per request in a backward fashion. You may penalize a user for being recommended in the near past. For the specific user, rotationRate=1 means maximal rotation, rotationRate=0 means absolutely no rotation. You may also use, for example, rotationRate=0.2 for only slight rotation of recommended users.


Number
Located in: body
Required: No
Since version: 5.0.0

Expert option: Taking rotationRate into account, specifies how long it takes for a user to recover from the penalization. For example, rotationTime=7200.0 means that users recommended less than 2 hours ago are penalized.


Successful operation.

{
  "recommId": "f88d970d-561c-460f-b4d4-faf0478244ca",
  "recomms": [
    {
      "id": "user-64"
    },
    {
      "id": "user-42"
    },
    {
      "id": "user-23"
    }
  ],
  "numberNextRecommsCalls": 0
}

userId does not match ^[a-zA-Z0-9_-:@.]+$, count is not a positive integer, filter or booster is not valid ReQL expressions, filter expression does not return boolean, booster does not return double or integer.


userId not found in the database and cascadeCreate is false. If there is no additional info in the JSON response, you probably have an error in your URL.


post

Recommends users that are likely to be interested in the given item.

It is also possible to use GET HTTP method - body parameters then become query parameters.

The returned users are sorted by predicted interest in the item (the first user being the most interested).

Copy
Initialization
const result = await client.send(new requests.RecommendUsersToItem(itemId, count, {
  // optional parameters:
  scenario: 'homepage',                                                // string
  cascadeCreate: true,                                                 // boolean
  returnProperties: true,                                              // boolean
  includedProperties: ['username', 'country'],                         // array
  filter: '\'country\' == "US"',                                       // string
  booster: 'if \'country\' == context_user["country"] then 2 else 1',  // string
  logic: 'recombee:default',                                           // string / Object
  reqlExpressions: {
    isInUsersCity: 'context_user["city"] in \'cities\'',
  },                                                                   // Object
}));

2.0.0

String
Located in: path
Required: Yes
Since version: 2.0.0

ID of your database.


String
Located in: path
Required: Yes
Since version: 2.0.0

ID of the item for which the recommendations are to be generated.


Integer
Located in: body
Required: Yes
Since version: 2.0.0

Number of users to be recommended (N for the top-N recommendation).


String
Located in: body
Required: No
Since version: 2.0.0

Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing".

You can set various settings to the scenario in the Admin UI. You can also see the performance of each scenario in the Admin UI separately, so you can check how well each application performs.

The AI that optimizes models to get the best results may optimize different scenarios separately or even use different models in each of the scenarios.


Boolean
Located in: body
Required: No
Since version: 2.0.0

If an item of the given itemId doesn't exist in the database, it creates the missing item.


Boolean
Located in: body
Required: No
Since version: 2.0.0

With returnProperties=true, property values of the recommended users are returned along with their IDs in a JSON dictionary. The acquired property values can be used to easily display the recommended users.

Example response:

  {
    "recommId": "039b71dc-b9cc-4645-a84f-62b841eecfce",
    "recomms":
      [
        {
          "id": "user-17",
          "values": {
            "country": "US",
            "sex": "F"
          }
        },
        {
          "id": "user-2",
          "values": {
            "country": "CAN",
            "sex": "M"
          }
        }
      ],
    "numberNextRecommsCalls": 0
  }

Array
Located in: body
Required: No
Since version: 2.0.0

Allows specifying which properties should be returned when returnProperties=true is set. The properties are given as a comma-separated list.

Example response for includedProperties=country:

  {
    "recommId": "b2b355dd-972a-4728-9c6b-2dc229db0678",
    "recomms":
      [
        {
          "id": "user-17",
          "values": {
            "country": "US"
          }
        },
        {
          "id": "user-2",
          "values": {
            "country": "CAN"
          }
        }
      ],
    "numberNextRecommsCalls": 0
  }

String
Located in: body
Required: No
Since version: 2.0.0

Boolean-returning ReQL expression, which allows you to filter recommended users based on the values of their attributes.

Filters can also be assigned to a scenario in the Admin UI.


String
Located in: body
Required: No
Since version: 2.0.0

Number-returning ReQL expression, which allows you to boost the recommendation rate of some users based on the values of their attributes.

Boosters can also be assigned to a scenario in the Admin UI.


String
Object
Located in: body
Required: No
Since version: 2.4.0

Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case. See this section for a list of available logics and other details.

The difference between logic and scenario is that logic specifies mainly behavior, while scenario specifies the place where recommendations are shown to the users.

Logic can also be set to a scenario in the Admin UI.


Object
Located in: body
Required: No
Since version: 6.0.0

A dictionary of ReQL expressions that will be executed for each recommended user. This can be used to compute additional properties of the recommended users that are not stored in the database.

The keys are the names of the expressions, and the values are the actual ReQL expressions.

Example request:

{
  "reqlExpressions": {
    "isInUsersCity": "context_user[\"city\"] in 'cities'",
    "distanceToUser": "earth_distance('location', context_user[\"location\"])",
    "isFromSameCompany": "'company' == context_item[\"company\"]"
  }
}

Example response:

{
  "recommId": "ce52ada4-e4d9-4885-943c-407db2dee837",
  "recomms": 
    [
      {
        "id": "restaurant-178",
        "reqlEvaluations": {
          "isInUsersCity": true,
          "distanceToUser": 5200.2,
          "isFromSameCompany": false
        }
      },
      {
        "id": "bar-42",
        "reqlEvaluations": {
          "isInUsersCity": false,
          "distanceToUser": 2516.0,
          "isFromSameCompany": true
        }
      }
    ],
   "numberNextRecommsCalls": 0
}

Successful operation.

{
  "recommId": "ee94fa8b-efe7-4b35-abc6-2bc3456d66ed",
  "recomms": [
    {
      "id": "user-64"
    },
    {
      "id": "user-42"
    },
    {
      "id": "user-23"
    }
  ],
  "numberNextRecommsCalls": 0
}

itemId does not match ^[a-zA-Z0-9_-:@.]+$, count is not a positive integer, filter or booster is not valid ReQL expressions, filter expression does not return boolean, booster does not return double or integer.


itemId not found in the database and cascadeCreate is false. If there is no additional info in the JSON response, you probably have an error in your URL.


Composite Recommendations return a source entity (e.g., an Item, or Item Segment) and a list of related recommendations in a single response, enabling multi-layered, highly personalized suggestions, such as Because You Watched … in streaming services or Top Products from Your Favorite Brand … in e-commerce.

post
Allowed on Client-Side

Composite Recommendation returns both a source entity (e.g., an Item or Item Segment) and a list of related recommendations in a single response.

It is ideal for use cases such as personalized homepage sections (Articles from <category>), Because You Watched <movie>, or Artists Related to Your Favorite Artist <artist>.

See detailed examples and configuration guidance in the Composite Scenarios documentation.

Structure

The endpoint operates in two stages:

  1. Recommends the source (e.g., an Item Segment or item) to the user.
  2. Recommends results (items or Item Segments) related to that source.

For example, Articles from <category> can be decomposed into:

Since the first step uses Recommend Item Segments To User, you must include the userId parameter in the Composite Recommendation request.

Each Composite Recommendation counts as a single recommendation API request for billing.

Stage-specific Parameters

Additional parameters can be supplied via sourceSettings and resultSettings. In the example above:

See this example for more details.

Copy
Initialization
const result = await client.send(new recombee.CompositeRecommendation(scenario, count, {
  // optional parameters:
  itemId: 'item-1',                                                        // string
  userId: 'user-1',                                                        // string
  logic: 'recombee:items-from-top-segment-for-you',                        // string / Object
  segmentId: 'segment-1',                                                  // string
  searchQuery: 'shoes',                                                    // string
  cascadeCreate: true,                                                     // boolean
  sourceSettings: {
    returnProperties: true,                                                // boolean
    includedProperties: ['title', 'price', 'publishedAt'],                 // array
    filter: 'price > 50',                                                  // string
    booster: 'if now() - \'publishedAt\' <= 7 * 24 * 3600 then 2 else 1',  // string
    logic: 'recombee:default',                                             // string / Object
    reqlExpressions: {
      isInUsersCity: 'context_user["city"] in \'cities\'',
    },                                                                     // Object
    minRelevance: 'low',                                                   // string
    rotationRate: 0.1,                                                     // number
    rotationTime: 7200.0,                                                  // number
  },
  resultSettings: {
    returnProperties: true,                                                // boolean
    includedProperties: ['title', 'price', 'publishedAt'],                 // array
    filter: 'price > 50',                                                  // string
    booster: 'if now() - \'publishedAt\' <= 7 * 24 * 3600 then 2 else 1',  // string
    logic: 'recombee:default',                                             // string / Object
    reqlExpressions: {
      isInUsersCity: 'context_user["city"] in \'cities\'',
    },                                                                     // Object
    minRelevance: 'low',                                                   // string
    rotationRate: 0.1,                                                     // number
    rotationTime: 7200.0,                                                  // number
  },
}));

6.0.0

String
Located in: path
Required: Yes
Since version: 6.0.0

ID of your database.


String
Located in: body
Required: Yes
Since version: 6.0.0

Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing".

You can set various settings to the scenario in the Admin UI. You can also see the performance of each scenario in the Admin UI separately, so you can check how well each application performs.

The AI that optimizes models to get the best results may optimize different scenarios separately or even use different models in each of the scenarios.


Integer
Located in: body
Required: Yes
Since version: 6.0.0

Number of items to be recommended (N for the top-N recommendation).


String
Located in: body
Required: No
Since version: 6.0.0

ID of the item for which the recommendations are to be generated.


String
Located in: body
Required: No
Since version: 6.0.0

ID of the user for which the recommendations are to be generated.


String
Object
Located in: body
Required: No
Since version: 6.0.0

Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case. See this section for a list of available logics and other details.

The difference between logic and scenario is that logic specifies mainly behavior, while scenario specifies the place where recommendations are shown to the users.

Logic can also be set to a scenario in the Admin UI.


String
Located in: body
Required: No
Since version: 6.0.0

ID of the segment from contextSegmentationId for which the recommendations are to be generated.


String
Located in: body
Required: No
Since version: 6.2.0

Search query provided by the user. It is used for the full-text search. Only applicable if the scenario corresponds to a search scenario.


Boolean
Located in: body
Required: No
Since version: 6.0.0

If the entity for the source recommendation does not exist in the database, returns a list of non-personalized recommendations and creates the user in the database. This allows, for example, rotations in the following recommendations for that entity, as the entity will be already known to the system.


Object
Located in: body
Required: No
Since version: 6.0.0

Parameters applied for recommending the Source stage. The accepted parameters correspond with the recommendation sub-endpoint used to recommend the Source.

Boolean
Located in: body
Required: No
Since version: 6.0.0

With returnProperties=true, property values of the recommended items are returned along with their IDs in a JSON dictionary. The acquired property values can be used to easily display the recommended items to the user.

Example response with returnProperties set in the resultSettings:

    {
      "recommId": "ee94fa8b-efe7-4b35-abc6-2bc3456d66ed",
      "source": {
        "id": "category-sport"
      },
      "recomms": [
        {
          "id": "article-1024",
          "values": {
            "title": "Champions League: Stunning Comeback Secures Final Spot",
            "categories": ["Sport", "Football"],
            "author": "Jane Smith",
            "url": "newsportal.com/articles/champions-league-comeback"
          }
        },
        {
          "id": "article-2031",
          "values": {
            "title": "Top 10 Moments from the Summer Olympics",
            "categories": ["Sport", "Olympics"],
            "author": "Mark Johnson",
            "url": "newsportal.com/articles/olympic-top-moments"
          }
        },
        {
          "id": "article-3042",
          "values": {
            "title": "Rising Stars in Women's Tennis to Watch This Season",
            "categories": ["Sport", "Tennis"],
            "author": "Laura Chen",
            "url": "newsportal.com/articles/womens-tennis-stars"
          }
        }
      ],
      "numberNextRecommsCalls": 0
    }

Array
Located in: body
Required: No
Since version: 6.0.0

Allows specifying which properties should be returned when returnProperties=true is set. The properties are given as a comma-separated list.

Example response for returnProperties=true and includedProperties=title,url set in resultSettings:

  {
    "recommId": "ee94fa8b-efe7-4b35-abc6-2bc3456d66ed",
    "source": {
      "id": "category-sport"
    },
    "recomms": [
      {
        "id": "article-1024",
        "values": {
          "title": "Champions League: Stunning Comeback Secures Final Spot",
          "url": "newsportal.com/articles/champions-league-comeback"
        }
      },
      {
        "id": "article-2031",
        "values": {
          "title": "Top 10 Moments from the Summer Olympics",
          "url": "newsportal.com/articles/olympic-top-moments"
        }
      },
      {
        "id": "article-3042",
        "values": {
          "title": "Rising Stars in Women's Tennis to Watch This Season",
          "url": "newsportal.com/articles/womens-tennis-stars"
        }
      }
    ],
    "numberNextRecommsCalls": 0
  }

String
Located in: body
Required: No
Since version: 6.0.0

Boolean-returning ReQL expression, which allows you to filter recommended entities based on the values of their attributes.

Filters can also be assigned to a scenario in the Admin UI.


String
Located in: body
Required: No
Since version: 2.0.0

Number-returning ReQL expression, which allows you to boost the recommendation rate of some entities based on the values of their attributes.

Boosters can also be assigned to a scenario in the Admin UI.


String
Object
Located in: body
Required: No
Since version: 6.0.0

Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case. See this section for a list of available logics and other details.

The difference between logic and scenario is that logic specifies mainly behavior, while scenario specifies the place where recommendations are shown to the users.

Logic can also be set to a scenario in the Admin UI.


Object
Located in: body
Required: No
Since version: 6.0.0

Only usable if the stage corresponds to the one of these recommendation endpoints:

A dictionary of ReQL expressions that will be executed for each recommended item. This can be used to compute additional properties of the recommended items that are not stored in the database.

The keys are the names of the expressions, and the values are the actual ReQL expressions.

Example request:

{
  "reqlExpressions": {
    "isInUsersCity": "context_user[\"city\"] in 'cities'",
    "distanceToUser": "earth_distance('location', context_user[\"location\"])"
  }
}

Example response:

{
  "recommId": "ce52ada4-e4d9-4885-943c-407db2dee837",
  "source": {
    "id": "restaurant-123",
    "reqlEvaluations": {
      "isInUsersCity": true,
      "distanceToUser": 3450.5
    }
  },
  "recomms": 
    [
      {
        "id": "restaurant-178",
        "reqlEvaluations": {
          "isInUsersCity": true,
          "distanceToUser": 5200.2
        }
      },
      {
        "id": "bar-42",
        "reqlEvaluations": {
          "isInUsersCity": false,
          "distanceToUser": 2516.0
        }
      }
    ],
   "numberNextRecommsCalls": 0
}

String
Located in: body
Required: No
Since version: 6.0.0

Expert option: Only usable if the stage corresponds to the one of these recommendation endpoints:

If the userId is provided: Specifies the threshold of how relevant must the recommended items be to the user.

Possible values one of: "low", "medium", "high".

The default value is "low", meaning that the system attempts to recommend a number of items equal to count at any cost. If there is not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations being appended to reach the full count. This behavior may be suppressed by using "medium" or "high" values. In such case, the system only recommends items of at least the requested relevance and may return less than count items when there is not enough data to fulfill it.


Number
Located in: body
Required: No
Since version: 6.0.0

Expert option: Only usable if the stage corresponds to the one of these recommendation endpoints:

If the userId is provided: If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per request in a backward fashion.

You may penalize an item for being recommended in the near past. For the specific user, rotationRate=1 means maximal rotation, rotationRate=0 means absolutely no rotation. You may also use, for example, rotationRate=0.2 for only slight rotation of recommended items.


Number
Located in: body
Required: No
Since version: 6.0.0

Expert option: Only usable if the stage corresponds to the one of these recommendation endpoints:

If the userId is provided: Taking rotationRate into account, specifies how long it takes for an item to recover from the penalization. For example, rotationTime=7200.0 means that items recommended less than 2 hours ago are penalized.


Object
Located in: body
Required: No
Since version: 6.0.0

Parameters applied for recommending the Result stage. The accepted parameters correspond with the recommendation sub-endpoint used to recommend the Result.

Boolean
Located in: body
Required: No
Since version: 6.0.0

With returnProperties=true, property values of the recommended items are returned along with their IDs in a JSON dictionary. The acquired property values can be used to easily display the recommended items to the user.

Example response with returnProperties set in the resultSettings:

    {
      "recommId": "ee94fa8b-efe7-4b35-abc6-2bc3456d66ed",
      "source": {
        "id": "category-sport"
      },
      "recomms": [
        {
          "id": "article-1024",
          "values": {
            "title": "Champions League: Stunning Comeback Secures Final Spot",
            "categories": ["Sport", "Football"],
            "author": "Jane Smith",
            "url": "newsportal.com/articles/champions-league-comeback"
          }
        },
        {
          "id": "article-2031",
          "values": {
            "title": "Top 10 Moments from the Summer Olympics",
            "categories": ["Sport", "Olympics"],
            "author": "Mark Johnson",
            "url": "newsportal.com/articles/olympic-top-moments"
          }
        },
        {
          "id": "article-3042",
          "values": {
            "title": "Rising Stars in Women's Tennis to Watch This Season",
            "categories": ["Sport", "Tennis"],
            "author": "Laura Chen",
            "url": "newsportal.com/articles/womens-tennis-stars"
          }
        }
      ],
      "numberNextRecommsCalls": 0
    }

Array
Located in: body
Required: No
Since version: 6.0.0

Allows specifying which properties should be returned when returnProperties=true is set. The properties are given as a comma-separated list.

Example response for returnProperties=true and includedProperties=title,url set in resultSettings:

  {
    "recommId": "ee94fa8b-efe7-4b35-abc6-2bc3456d66ed",
    "source": {
      "id": "category-sport"
    },
    "recomms": [
      {
        "id": "article-1024",
        "values": {
          "title": "Champions League: Stunning Comeback Secures Final Spot",
          "url": "newsportal.com/articles/champions-league-comeback"
        }
      },
      {
        "id": "article-2031",
        "values": {
          "title": "Top 10 Moments from the Summer Olympics",
          "url": "newsportal.com/articles/olympic-top-moments"
        }
      },
      {
        "id": "article-3042",
        "values": {
          "title": "Rising Stars in Women's Tennis to Watch This Season",
          "url": "newsportal.com/articles/womens-tennis-stars"
        }
      }
    ],
    "numberNextRecommsCalls": 0
  }

String
Located in: body
Required: No
Since version: 6.0.0

Boolean-returning ReQL expression, which allows you to filter recommended entities based on the values of their attributes.

Filters can also be assigned to a scenario in the Admin UI.


String
Located in: body
Required: No
Since version: 2.0.0

Number-returning ReQL expression, which allows you to boost the recommendation rate of some entities based on the values of their attributes.

Boosters can also be assigned to a scenario in the Admin UI.


String
Object
Located in: body
Required: No
Since version: 6.0.0

Logic specifies the particular behavior of the recommendation models. You can pick tailored logic for your domain and use case. See this section for a list of available logics and other details.

The difference between logic and scenario is that logic specifies mainly behavior, while scenario specifies the place where recommendations are shown to the users.

Logic can also be set to a scenario in the Admin UI.


Object
Located in: body
Required: No
Since version: 6.0.0

Only usable if the stage corresponds to the one of these recommendation endpoints:

A dictionary of ReQL expressions that will be executed for each recommended item. This can be used to compute additional properties of the recommended items that are not stored in the database.

The keys are the names of the expressions, and the values are the actual ReQL expressions.

Example request:

{
  "reqlExpressions": {
    "isInUsersCity": "context_user[\"city\"] in 'cities'",
    "distanceToUser": "earth_distance('location', context_user[\"location\"])"
  }
}

Example response:

{
  "recommId": "ce52ada4-e4d9-4885-943c-407db2dee837",
  "source": {
    "id": "restaurant-123",
    "reqlEvaluations": {
      "isInUsersCity": true,
      "distanceToUser": 3450.5
    }
  },
  "recomms": 
    [
      {
        "id": "restaurant-178",
        "reqlEvaluations": {
          "isInUsersCity": true,
          "distanceToUser": 5200.2
        }
      },
      {
        "id": "bar-42",
        "reqlEvaluations": {
          "isInUsersCity": false,
          "distanceToUser": 2516.0
        }
      }
    ],
   "numberNextRecommsCalls": 0
}

String
Located in: body
Required: No
Since version: 6.0.0

Expert option: Only usable if the stage corresponds to the one of these recommendation endpoints:

If the userId is provided: Specifies the threshold of how relevant must the recommended items be to the user.

Possible values one of: "low", "medium", "high".

The default value is "low", meaning that the system attempts to recommend a number of items equal to count at any cost. If there is not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations being appended to reach the full count. This behavior may be suppressed by using "medium" or "high" values. In such case, the system only recommends items of at least the requested relevance and may return less than count items when there is not enough data to fulfill it.


Number
Located in: body
Required: No
Since version: 6.0.0

Expert option: Only usable if the stage corresponds to the one of these recommendation endpoints:

If the userId is provided: If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per request in a backward fashion.

You may penalize an item for being recommended in the near past. For the specific user, rotationRate=1 means maximal rotation, rotationRate=0 means absolutely no rotation. You may also use, for example, rotationRate=0.2 for only slight rotation of recommended items.


Number
Located in: body
Required: No
Since version: 6.0.0

Expert option: Only usable if the stage corresponds to the one of these recommendation endpoints:

If the userId is provided: Taking rotationRate into account, specifies how long it takes for an item to recover from the penalization. For example, rotationTime=7200.0 means that items recommended less than 2 hours ago are penalized.


Successful operation.

{
  "recommId": "ee94fa8b-efe7-4b35-abc6-2bc3456d66ed",
  "source": {
    "id": "category-4"
  },
  "recomms": [
    {
      "id": "item-64"
    },
    {
      "id": "item-42"
    },
    {
      "id": "item-23"
    }
  ],
  "numberNextRecommsCalls": 0
}

Count is not a positive integer, provided scenario not found.


contextSegmentId not found in the context segmentation, userId not found in the database and cascadeCreate is false, itemId not found in the database and cascadeCreate is false.


Suppose you want to recommend three category sections on the homepage, but in a personalized order for each user.
For example, in a news domain, one user might see Politics–Culture–Technology, while another might get Sport–Technology–Politics.

You can achieve this by calling three Composite Recommendations within a single Batch request — retrieving both the personalized categories and the recommended items within each.

The Batch ensures that three distinct categories are returned in the results.

Example response:

[
  {
    "code": 200,
    "json": {
      "recommId": "c8f25d2a-5c39-4c45-b42b-6a7d4e6b1c52",
      "source": { "id": "category-sport" },
      "recomms": [
        { "id": "article-1024" },
        { "id": "article-2031" },
        { "id": "article-3042" }
      ],
      "numberNextRecommsCalls": 0
    }
  },
  {
    "code": 200,
    "json": {
      "recommId": "b31f16e2-f4e9-43e8-b22f-9da78a5e8e33",
      "source": { "id": "category-technology" },
      "recomms": [
        { "id": "article-501" },
        { "id": "article-507" },
        { "id": "article-519" }
      ],
      "numberNextRecommsCalls": 0
    }
  },
  {
    "code": 200,
    "json": {
      "recommId": "3f6ad2f2-a3f1-4ba1-a690-f4f01f76d4eb",
      "source": { "id": "category-politics" },
      "recomms": [
        { "id": "article-146" },
        { "id": "article-462" },
        { "id": "article-463" }
      ],
      "numberNextRecommsCalls": 0
    }
  }
]

Requesting recommendations:

Copy
const batchRequest = new recombee.Batch([
  new recombee.CompositeRecommendation('homepage-category-section', 6, { userId: userId }),
  new recombee.CompositeRecommendation('homepage-category-section', 6, { userId: userId }),
  new recombee.CompositeRecommendation('homepage-category-section', 6, { userId: userId })
], {
  distinctRecomms: true
});

const responses = await client.send(batchRequest);

This example shows how to use parameters on both stages:

  • In sourceSettings, we enable rotation so the source changes over time for the same user.
  • In resultSettings, we filter out promotions and return basic properties for rendering.

Example response (truncated) with returnProperties=true on results:

{
  "recommId": "7b8d0f5e-42a4-4a71-b2b7-25f9c0cc0e9a",
  "source": { "id": "article-389" },
  "recomms": [
    {
      "id": "article-1024",
      "values": { "title": "5 Books That Will Change How You Think", "url": "newsportal.com/a/1024" }
    },
    {
      "id": "article-2031",
      "values": { "title": "The Psychology of Habit Formation", "url": "newsportal.com/a/2031" }
    }
  ],
  "numberNextRecommsCalls": 0
}

Requesting recommendations:

Copy
const req = new recombee.CompositeRecommendation(
  'because-you-read',
  10,
  {
    userId: userId,
    sourceSettings: {
      rotationRate: 0.5,
      rotationTime: 7200
    },
    resultSettings: {
      filter: "'type' != \"promotion\"",
      returnProperties: true,
      includedProperties: ['title', 'url']
    }
  }
);

const response = await client.send(req);
© Copyright 2026, Recombee s.r.o
docs.recombee.com