> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# GetRecommendation

# Package: recommendations

# Namespace: RecommendationsService

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/other-services/recommendations/recommendations/get-recommendation.md

## Permission Scopes:
Read eCommerce - all read permissions: SCOPE.DC-ECOM-MEGA.READ-ECOM

## Introduction

Returns a list of items to recommend to site visitors based on the specified algorithms.

You can specify multiple algorithms in the request. The method processes them in order and returns the recommendations from the first algorithm that meets the `minimumRecommendedItems` threshold. If the first algorithm doesn't provide enough items, the method moves to the next algorithm in the list and repeats the process. If no algorithm meets the threshold, the method returns an empty array.

> **Notes:**
> - Both the app providing the algorithm and an app providing a supported catalog must be installed on the site.
> - This method doesn't run the algorithms directly. It calls the installed apps that provide them.

To see which algorithms are available on a site, call [List Available Algorithms](https://dev.wix.com/docs/rest/api-reference/wix-e-commerce/recommendations/list-available-algorithms.md).

---

## REST API

### Schema

```
 Method: getRecommendation
 Description: Returns a list of items to recommend to site visitors based on the specified algorithms.  You can specify multiple algorithms in the request. The method processes them in order and returns the recommendations from the first algorithm that meets the `minimumRecommendedItems` threshold. If the first algorithm doesn't provide enough items, the method moves to the next algorithm in the list and repeats the process. If no algorithm meets the threshold, the method returns an empty array.  > **Notes:** > - Both the app providing the algorithm and an app providing a supported catalog must be installed on the site. > - This method doesn't run the algorithms directly. It calls the installed apps that provide them.  To see which algorithms are available on a site, call [List Available Algorithms](https://dev.wix.com/docs/rest/api-reference/wix-e-commerce/recommendations/list-available-algorithms.md).
 URL: https://www.wixapis.com/v1/recommendations/get
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  algorithms, algorithms.id, algorithms.appId, items.appId, items.catalogItemId
 Method parameters: 
   param name: algorithms | type: array<algorithms> | description: Algorithms to specify for generating recommendations, ordered by preference. The method processes algorithms in order and provides recommendations from the first algorithm that meets the `minimumRecommendedItems` threshold. | required: true | validation: minItems 1, maxItems 10
              - name: id | type: string | description: GUID of the algorithm, as defined by the app that provides it. | required: true | validation: format GUID
              - name: appId | type: string | description: GUID of the app providing the algorithm. This can be an app built by Wix or a 3rd-party app.  See app GUIDs for [apps built by Wix](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/platform/about-apps-created-by-wix.md). | required: true | validation: minLength 1, maxLength 36
   param name: items | type: array<items> | description: Catalog items to base recommendations on. Required if the algorithm's `algorithmType` is `RELATED_ITEMS`.  | validation: maxItems 300
              - name: catalogItemId | type: string | description: GUID of the item within the catalog it belongs to. | required: true | validation: minLength 1, maxLength 36
              - name: appId | type: string | description: GUID of the app providing the catalog.  You can get your app's GUID from its page in the [app dashboard](https://dev.wix.com/dc3/my-apps/).  For items from Wix catalogs, the following values always apply: + Wix Stores: `"215238eb-22a5-4c36-9e7b-e7c08025e04e"` + Wix Bookings: `"13d21c63-b5ec-5912-8397-c3a5ddb27a97"` + Wix Restaurants: `"9a5d83fd-8570-482e-81ab-cfa88942ee60"` | required: true | validation: minLength 1
              - name: options | type: object | description: Additional item details in `key:value` pairs.  Use this optional field for more specificity with item selection. The values of the `options` field differ depending on which catalog is providing the items.  For Wix Stores products, learn more about integrating with [Catalog V3](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v3/e-commerce-integration.md) or [Catalog V1](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v1/catalog/e-commerce-integration.md), depending on [the version the site uses](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-versioning/introduction.md).  
   param name: minimumRecommendedItems | type: minimumRecommendedItems | description: Minimum number of items an algorithm must provide for its recommendations to be returned in the response. If no algorithm provides enough items, an empty array is returned.  | validation: minimum 0, maximum 100
 Return type: GetRecommendationResponse
  - name: recommendation | type: Recommendation | description: The recommended items and the algorithm that provided them. Empty if no algorithm met the `minimumRecommendedItems` threshold.  
     - name: items | type: array<CatalogReference> | description: Recommended items.  | validation: maxItems 100
        - name: catalogItemId | type: string | description: GUID of the item within the catalog it belongs to.  | validation: minLength 1, maxLength 36
        - name: appId | type: string | description: GUID of the app providing the catalog.  You can get your app's GUID from its page in the [app dashboard](https://dev.wix.com/dc3/my-apps/).  For items from Wix catalogs, the following values always apply: + Wix Stores: `"215238eb-22a5-4c36-9e7b-e7c08025e04e"` + Wix Bookings: `"13d21c63-b5ec-5912-8397-c3a5ddb27a97"` + Wix Restaurants: `"9a5d83fd-8570-482e-81ab-cfa88942ee60"`  | validation: minLength 1
        - name: options | type: object | description: Additional item details in `key:value` pairs.  Use this optional field for more specificity with item selection. The values of the `options` field differ depending on which catalog is providing the items.  For Wix Stores products, learn more about integrating with [Catalog V3](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v3/e-commerce-integration.md) or [Catalog V1](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v1/catalog/e-commerce-integration.md), depending on [the version the site uses](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-versioning/introduction.md).  
     - name: algorithm | type: Algorithm | description: The algorithm used to provide the recommendation.  
        - name: id | type: string | description: GUID of the algorithm, as defined by the app that provides it.  | validation: format GUID
        - name: appId | type: string | description: GUID of the app providing the algorithm. This can be an app built by Wix or a 3rd-party app.  See app GUIDs for [apps built by Wix](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/platform/about-apps-created-by-wix.md).  | validation: minLength 1, maxLength 36

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: ALGORITHM_NOT_SUPPORTED | Description: One or more algorithms in the `algorithms` array aren't supported by the provider.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: ITEM_APP_ID_NOT_SUPPORTED | Description: The `items` array contains app GUIDs that aren't supported by the specified algorithm.
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: RECOMMENDATIONS_PROVIDER_NOT_FOUND | Description: Couldn't find the recommendation provider.


```

### Examples

### GetRecommendation
```curl
~~~cURL
curl POST 'www.wixapis.com/ecom/v1/recommendations/get' \
-H 'Content-Type: application/json;charset=UTF-8' \
-H 'Authorization: <AUTH>' \
--data-binary '{
     "items": [
         {
             "catalogItemId": "ec7914e8-208b-0069-5850-1a965643508d",
             "appId": "f29c9b39-1090-4d9b-8e3a-a3a681a57970"
         }
     ],
     "algorithms": [
         {
             "id": "e33f5e32-d1a2-4944-b38f-d29b7d5ef4ef",
             "appId": "72454cb3-90b5-4cef-bbff-cc61aea02584"
         },
         {
             "id": "09dc98e8-8696-49f7-833a-bab57f516f88",
             "appId": "b0933968-e643-4835-a403-de8e1eb4d33c"
         }
     ],
     "minimumRelatedItems": 1
}'
~~~
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.ecom.recommendations.getRecommendation(algorithms, options)
 Description: Returns a list of items to recommend to site visitors based on the specified algorithms.  You can specify multiple algorithms in the request. The method processes them in order and returns the recommendations from the first algorithm that meets the `minimumRecommendedItems` threshold. If the first algorithm doesn't provide enough items, the method moves to the next algorithm in the list and repeats the process. If no algorithm meets the threshold, the method returns an empty array.  > **Notes:** > - Both the app providing the algorithm and an app providing a supported catalog must be installed on the site. > - This method doesn't run the algorithms directly. It calls the installed apps that provide them.  To see which algorithms are available on a site, call [List Available Algorithms](https://dev.wix.com/docs/rest/api-reference/wix-e-commerce/recommendations/list-available-algorithms.md).
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  algorithms, algorithms._id, algorithms.appId, options.items.appId, options.items.catalogItemId
 Method parameters: 
   param name: algorithms | type: array<Algorithm> | description: Algorithms to specify for generating recommendations, ordered by preference. The method processes algorithms in order and provides recommendations from the first algorithm that meets the `minimumRecommendedItems` threshold. | required: true | validation: minItems 1, maxItems 10
              - name: _id | type: string | description: GUID of the algorithm, as defined by the app that provides it. | required: true | validation: format GUID
              - name: appId | type: string | description: GUID of the app providing the algorithm. This can be an app built by Wix or a 3rd-party app.  See app GUIDs for [apps built by Wix](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/platform/about-apps-created-by-wix.md). | required: true | validation: minLength 1, maxLength 36
   param name: options | type: GetRecommendationOptions  none  
        - name: items | type: array<CatalogReference> | description: Catalog items to base recommendations on. Required if the algorithm's `algorithmType` is `RELATED_ITEMS`.  | validation: maxItems 300
           - name: catalogItemId | type: string | description: GUID of the item within the catalog it belongs to.  | validation: minLength 1, maxLength 36
           - name: appId | type: string | description: GUID of the app providing the catalog.  You can get your app's GUID from its page in the [app dashboard](https://dev.wix.com/dc3/my-apps/).  For items from Wix catalogs, the following values always apply: + Wix Stores: `"215238eb-22a5-4c36-9e7b-e7c08025e04e"` + Wix Bookings: `"13d21c63-b5ec-5912-8397-c3a5ddb27a97"` + Wix Restaurants: `"9a5d83fd-8570-482e-81ab-cfa88942ee60"`  | validation: minLength 1
           - name: options | type: object | description: Additional item details in `key:value` pairs.  Use this optional field for more specificity with item selection. The values of the `options` field differ depending on which catalog is providing the items.  For Wix Stores products, learn more about integrating with [Catalog V3](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v3/e-commerce-integration.md) or [Catalog V1](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v1/catalog/e-commerce-integration.md), depending on [the version the site uses](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-versioning/introduction.md).  
        - name: minimumRecommendedItems | type: integer | description: Minimum number of items an algorithm must provide for its recommendations to be returned in the response. If no algorithm provides enough items, an empty array is returned.  | validation: minimum 0, maximum 100
 Return type: PROMISE<GetRecommendationResponse>
  - name: recommendation | type: Recommendation | description: The recommended items and the algorithm that provided them. Empty if no algorithm met the `minimumRecommendedItems` threshold.  
     - name: items | type: array<CatalogReference> | description: Recommended items.  | validation: maxItems 100
        - name: catalogItemId | type: string | description: GUID of the item within the catalog it belongs to.  | validation: minLength 1, maxLength 36
        - name: appId | type: string | description: GUID of the app providing the catalog.  You can get your app's GUID from its page in the [app dashboard](https://dev.wix.com/dc3/my-apps/).  For items from Wix catalogs, the following values always apply: + Wix Stores: `"215238eb-22a5-4c36-9e7b-e7c08025e04e"` + Wix Bookings: `"13d21c63-b5ec-5912-8397-c3a5ddb27a97"` + Wix Restaurants: `"9a5d83fd-8570-482e-81ab-cfa88942ee60"`  | validation: minLength 1
        - name: options | type: object | description: Additional item details in `key:value` pairs.  Use this optional field for more specificity with item selection. The values of the `options` field differ depending on which catalog is providing the items.  For Wix Stores products, learn more about integrating with [Catalog V3](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v3/e-commerce-integration.md) or [Catalog V1](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v1/catalog/e-commerce-integration.md), depending on [the version the site uses](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-versioning/introduction.md).  
     - name: algorithm | type: Algorithm | description: The algorithm used to provide the recommendation.  
        - name: _id | type: string | description: GUID of the algorithm, as defined by the app that provides it.  | validation: format GUID
        - name: appId | type: string | description: GUID of the app providing the algorithm. This can be an app built by Wix or a 3rd-party app.  See app GUIDs for [apps built by Wix](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/platform/about-apps-created-by-wix.md).  | validation: minLength 1, maxLength 36

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: ALGORITHM_NOT_SUPPORTED | Description: One or more algorithms in the `algorithms` array aren't supported by the provider.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: ITEM_APP_ID_NOT_SUPPORTED | Description: The `items` array contains app GUIDs that aren't supported by the specified algorithm.
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: RECOMMENDATIONS_PROVIDER_NOT_FOUND | Description: Couldn't find the recommendation provider.


```

### Examples

### Get recommendation with algorithms and options objects (with $w)
```javascript
/********************************************
 * Backend code - recommendations.web.js/ts *
 *******************************************/
import { Permissions, webMethod } from '@wix/web-methods';
import { recommendations } from '@wix/ecom';
  
export const getRecommendation = webMethod(Permissions.Anyone, async (algorithms, options) => {
  try {
    const result = await recommendations.getRecommendation(algorithms, options);

    return result;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
});

/*************
 * Page code *
 ************/

import { getRecommendation } from 'backend/recommendations.web';

$w.onReady(async function () {
  let algorithm = {
    appId: '215238eb-22a5-4c36-9e7b-e7c08025e04e',
    id: '68ebce04-b96a-4c52-9329-08fc9d8c1253'
  };
  let item = {
	appId: '215238eb-22a5-4c36-9e7b-e7c08025e04e',
	catalogItemId: '11e2ffb7-2520-3c21-051e-1f05486b9061'
  };
  let options = {
	items: [item],
	minimumRecommendedItems: 1
  }
  let recommendations = await getRecommendation([algorithm], options);
  console.log(recommendations);
});

```

### getRecommendation (self-managed)
Self-managed SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { recommendations } from '@wix/ecom';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { recommendations },
  // Include the auth strategy and host as relevant
});


async function getRecommendation(algorithms,options) {
  const response = await myWixClient.recommendations.getRecommendation(algorithms,options);
};
```

---