Introduction


The Recommendations API allows users to promote and recommend items to their customers. Items are selected from catalogs in installed Wix apps by algorithms also provided by installed Wix apps. Users can choose algorithms from among those available to get the types of recommendations they need. For example, an algorithm could provide a list of bestselling items, or items frequently bought together with some specified item/s.

With the Recommendations API, you can:

  • Get a list of recommendation algorithms available for use on your Wix site or project.
  • Get a list of recommended items given one or more algorithms

Before you begin

  • You must have an app installed on your project that implements the Recommendations Provider SPI and provides algorithms. You must also have an app installed whose catalogs those algorithms can apply to. (Currently, in both cases, this is only Wix Stores.)
  • Algorithms can only be applied to catalogs they support. To find out which catalogs an algorithm supports, call List Available Algorithms and check the catalogAppIds.

Terminology

  • Algorithm: Code that is used to identify and return items from a catalog based on some defined criteria, such as which items have the highest number of sales. Algorithms may take a list of products as input and use them in their calculations.
  • Catalog: A set of products or services defined in a Wix App. In this documentation, we refer to these products or services generally as “items”.
Was this helpful?
Yes
No

Setup

To use the Recommendations API, install the @wix/ecom package using npm or Yarn:

Copy
1
npm install @wix/ecom

or

Copy
1
yarn add @wix/ecom

Then import { recommendations } from @wix/ecom:

Copy
1
import { recommendations } from '@wix/ecom'
Was this helpful?
Yes
No

getRecommendation( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Returns a recommendation object containing a list of items to recommend to the customer.

getRecommendation() determines which items to recommend based on the given recommendation algorithms.

getRecommendation() doesn’t run the algorithms. It calls the installed apps that provide them.

Apps may provide algorithms for use with their own catalogs, or for use with catalogs from other apps. For example, Wix Stores provides algorithms that can only be used on its own catalogs. To run an algorithm, the app providing it must be installed, and an app providing a supported catalog must be installed. For more information and to see which algorithms are available on your site or project, call listAvailableAlgorithms().

getRecommendation() operates as follows:

  1. getRecommendation() receives as input a list of algorithms as an array. These algorithms can be provided by different apps and can apply to different catalogs.
  2. getRecommendation() calls the app that corresponds to the appId of the first algorithm in the list of algorithms. It passes that algorithm’s ID and the IDs of any subsequent algorithms in the array for the same app.
  3. The app runs the algorithms.
  4. getRecommendation() returns items recommendations from the first algorithm (according to its position in the algorithms array) that meets the minimum number of recommendations. At that point getRecommendation() stops calling other apps.
  5. If none of the algorithms run by the first app meet the minimum recommended items, getRecommendation() finds the next algorithm in the array with a new appId (an ID of an app that has not yet been called), and repeats the process.
  6. If no algorithms in the algorithms array recommend at least the minimum recommended items, getRecommendation() returns an empty array.

Permission Scopes

For app development, you must have one of the following permission scopes:
Read eCommerce - all read permissions
Learn more about permission scopes.
Copy
function getRecommendation(algorithms: Array<Algorithm>, options: GetRecommendationOptions): Promise<GetRecommendationResponse>
Method Parameters
algorithmsArray<Algorithm>Required

A list of algorithms checked in a specific order determined by their appID and their position in the algorithms array. See the method description for more information.

If no algorithm is able to return at least minimumRecommendedItems items, an empty array is returned.


optionsGetRecommendationOptions

Get recommendation options.

Returns
Return Type:Promise<GetRecommendationResponse>
Was this helpful?
Yes
No

listAvailableAlgorithms( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Returns a list of recommendation algorithms that can be used on your Wix site or project. These algorithms can be used with getRecommendation() to provide item recommendations to the customer.

Algorithms are run by the apps that provide them, and can only be used on catalogs they support. Apps may provide algorithms for use with their own catalogs and/or catalogs from other apps.

The app which provides an algorithm is referenced by that algorithm’s appId. The apps whose catalogs are supported by an algorithm are referenced by the IDs in that algorithm’s catalogAppIds array.

For an algorithm to be considered “Available” and returned in this method’s response, the algorithm must meet the following conditions:

  1. The algorithm’s appId must match the ID of an installed Wix app.
  2. At least 1 of the IDs in catalogAppIds must match the ID of an installed Wix app.

Wix app IDs are listed here.

Permission Scopes

For app development, you must have one of the following permission scopes:
Read eCommerce - all read permissions
Learn more about permission scopes.
Copy
function listAvailableAlgorithms(): Promise<ListAvailableAlgorithmsResponse>
Request
This method does not take any parameters
Returns
Return Type:Promise<ListAvailableAlgorithmsResponse>
Was this helpful?
Yes
No