Skip to content

Trending items recommendation

The POST /v1/items/trending endpoint considers all kind of possible parameters in your application such as user behavior, item co-relation, external impact, business impact and returns the trending items for a given interval as response. You can use it on user feed, top page, personalized suggestions etc.


To use this feature, you have to first set up the key parameters for the ranking model via the endpoint POST /v1/ranks/settings.

Here is an example request body for this endpoint

{
  "rank_settings": {
    "interval": [
      "weekly",
      "bi-weekly",
      "monthly",
      "quarterly",
      "yearly"
    ],
    "split_size": 0.1,
    "epoch": 200
  }
}

Lets go through the parameters:

  • interval (Enum): An array specifying the time intervals for which the ranking model will compute ranks. Possible values are:weekly, bi-weekly, monthly, quarterly, yearly. We recommend to keep it as it is (Default value) unless you have any specific reason to change it.
  • split_size (Float): A decimal value representing the fraction of data to be used for training the ranking model. The data will be split into training and testing sets (X_train, X_test, y_train, y_test). For example, a split_size of 0.1 means 10% of the data will be used for training. If you are not sure about this parameter, please use the default value.
  • epoch (Integer): An integer value that sets the number of training iterations the ranking model will undergo. For instance, an epoch value of 200 means the model will train for 200 iterations. If you are not sure about this parameter, please use the default value.

You can always check the current setting using GET /v1/ranks/settings and update the setting using PUT /v1/ranks/settings.


Once the above setting is done, then you can set up the recommendation for trending items using the below endpoint:

POST /v1/items/trending

Here is a sample request body.

{
  "top_n_item": 100,
  "interval": "weekly",
  "details": true
}

Let’s go through the parameters:

  • top_n_item (Int): Represents number of top-ranked items in a given time interval.
  • interval (Enum): Selected enum value represents the time range for recommending trending items. Available values are weekly, bi-weekly, monthly, quarterly, yearly. Interval should be similar to the interval parameter of the POST /v1/ranks/settings endpoint mentioned earlier on this page. If you have set the default value there, then you can choose either of the Enum values.
  • details (Bool): If you want to get recommended items with the items details, this parameter would be True; otherwise, it would be False.