Skip to content

Sorting a product collection

Our SDK helps making requests against our API eaiser for you. It works both with strongly-typed TypeScript and with JavaScript. You can also use it direcly via a CDN provider. Read more about that here. If you do use it directly from a CDN, then all of our types are namespaced with a Relewise.-prefix. So to get the recommender you need to write new Relewise.Recommender() instead of new Recommender().

To get started with recommendations we need to start by making an Recommender-instance.

const recommender = new Recommender(RELEWISE_DATASET_ID, RELEWISE_API_KEY, {

Before going any further, make sure you have read the following:

  • Read about how to authenticate against our API here.
  • Read about handling different types of users here.

Sorting Products

When using your own search engine and want to get a personalized sorting of a collection of products you can use our SortProducts-recommendation to achieve this. The recommended way of using Relewise for category pages is using our search features. Read about how to use our Search API for category pages here.

Parse in the product ids you want personalized, and specificy the number of recommendations you want back. If you want a subset of the collection, you can just set a specific amount you want returned.

const settings: Settings = {
    language: 'da-DK',
    currency: 'DKK',
    displayedAtLocation: 'Product Details Page',
    user: getUser()

const productIds = ['p-1', 'p-2', 'p-3'];

const builder = new SortProductsBuilder(settings)

await recommender.sortProducts(;

You can still use filters, relevance modifiers and of course select what product and variant properties you want returned in the response.

Don't know us? Don't worry - you can find more information about us, by visiting our main page