> 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`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # GetRecommendations # Package: recommendations # Namespace: RecommendationsProvider # Method link: https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/other-services/recommendations/recommendations-service-plugin/get-recommendations.md ## Introduction This method retrieves an array containing the lists of recommended items returned by each algorithm. Items must be selected from catalogs in Wix apps installed on the site. If a requested recommendation algorithm's type is `RELATED_ITEMS` then the `items` field is included in the request. The response should contain items related to those submitted. How the related items are selected depends on the recommendation algorithms used. For example, items can be in the same category, or can be frequently bought or watched together. --- ## REST API ### Schema ``` Method: getRecommendations Description: This method retrieves an array containing the lists of recommended items returned by each algorithm. Items must be selected from catalogs in Wix apps installed on the site. If a requested recommendation algorithm's type is `RELATED_ITEMS` then the `items` field is included in the request. The response should contain items related to those submitted. How the related items are selected depends on the recommendation algorithms used. For example, items can be in the same category, or can be frequently bought or watched together. URL: null Method: POST Method parameters: param name: algorithmIds | type: array | description: List of algorithms used to find recommended items. Items will be returned in a separate object for each algorithm param name: items | type: array | description: The set of items used by algorithms with the `RELATED_ITEMS` `algorithmType` to determine related item recommendations. - name: catalogItemId | type: string | description: GUID of the item within the catalog it belongs to. - 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"` - 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). Return type: GetRecommendationsResponse - name: recommendationPerAlgorithm | type: array | description: Related items returned by each algorithm. Each object in the array contains an `algorithmId` and a list of the item recommendations provided by that algorithm. - name: algorithmId | type: string | description: Id of the algorithm that provided the recommendation. - name: recommendedItems | type: array | description: Item recommendations provided by the algorithm. Depending on the algorithm, these recommendations may be influenced by the items provided in the request. - name: catalogItemId | type: string | description: GUID of the item within the catalog it belongs to. - 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"` - 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). Possible Errors: HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: ITEM_APP_ID_NOT_SUPPORTED | Description: One or more items are from catalogs that aren't supported by the provider. Only provide items from catalogs listed in the provider's `catalog_app_ids` configuration. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: ALGORITHM_NOT_SUPPORTED | Description: One or more of the requested `algorithm_ids` aren't supported by the provider. Check the provider's `supported_algorithms` configuration for valid algorithm GUIDs. ``` ### Examples ### GetRecommendations ```curl ~~~cURL curl POST 'www.wixapis.com/stores/recommendations/v1/get-recommendations' \ -H 'Content-Type: application/json;charset=UTF-8' \ -H 'Authorization: ' \ --data-binary '{ "items": [ { "catalogItemId": "ec7914e8-208b-0069-5850-1a965643508d", "appId": "f29c9b39-1090-4d9b-8e3a-a3a681a57970" } ], "algorithmIds": ["4197e48af4324989be1aa691fe37c53a", "09dc98e8-8696-49f7-833a-bab57f516f88"] }' ~~~ ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.recommendations.RecommendationsProvider.getRecommendations(request, metadata) Description: This method retrieves an array containing the lists of recommended items returned by each algorithm. Items must be selected from catalogs in Wix apps installed on the site. If a requested recommendation algorithm's type is `RELATED_ITEMS` then the `items` field is included in the request. The response should contain items related to those submitted. How the related items are selected depends on the recommendation algorithms used. For example, items can be in the same category, or can be frequently bought or watched together. Method parameters: param name: metadata | type: Context | description: this message is not directly used by any service, it exists to describe the expected parameters that SHOULD be provided to invoked Velo methods as part of open-platform. e.g. SPIs, event-handlers, etc.. NOTE: this context object MUST be provided as the last argument in each Velo method signature. Example: ```typescript export function wixStores_onOrderCanceled({ event, metadata }: OrderCanceledEvent) { ... } ``` - name: requestId | type: string | description: A unique identifier of the request. You may print this GUID to your logs to help with future debugging and easier correlation with Wix's logs. - name: currency | type: string | description: [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) 3-letter currency code. - name: identity | type: IdentificationData | description: An object that describes the identity that triggered this request. - ONE-OF: - name: anonymousVisitorId | type: string | description: GUID of a site visitor that has not logged in to the site. - name: memberId | type: string | description: GUID of a site visitor that has logged in to the site. - name: wixUserId | type: string | description: GUID of a Wix user (site owner, contributor, etc.). - name: appId | type: string | description: GUID of an app. - name: languages | type: array | description: A string representing a language and region in the format of `"xx-XX"`. First 2 letters represent the language code according to ISO 639-1. This is followed by a dash "-", and then a by 2 capital letters representing the region according to ISO 3166-2. For example, `"en-US"`. - name: instanceId | type: string | description: The service provider app's instance GUID. param name: request | type: GetRecommendationsRequest | description: additional information can be passed via aspects, for example GEO - name: items | type: array | description: The set of items used by algorithms with the `RELATED_ITEMS` `algorithmType` to determine related item recommendations. - name: catalogItemId | type: string | description: GUID of the item within the catalog it belongs to. - 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"` - 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: algorithmIds | type: array | description: List of algorithms used to find recommended items. Items will be returned in a separate object for each algorithm Return type: PROMISE - name: recommendationPerAlgorithm | type: array | description: Related items returned by each algorithm. Each object in the array contains an `algorithmId` and a list of the item recommendations provided by that algorithm. - name: algorithmId | type: string | description: Id of the algorithm that provided the recommendation. - name: recommendedItems | type: array | description: Item recommendations provided by the algorithm. Depending on the algorithm, these recommendations may be influenced by the items provided in the request. - name: catalogItemId | type: string | description: GUID of the item within the catalog it belongs to. - 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"` - 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). Possible Errors: HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: ITEM_APP_ID_NOT_SUPPORTED | Description: One or more items are from catalogs that aren't supported by the provider. Only provide items from catalogs listed in the provider's `catalog_app_ids` configuration. HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: ALGORITHM_NOT_SUPPORTED | Description: One or more of the requested `algorithm_ids` aren't supported by the provider. Check the provider's `supported_algorithms` configuration for valid algorithm GUIDs. ``` ### Examples ### getRecommendations ```javascript import { recommendationsProvider } from '@wix/ecom/service-plugins'; async function getRecommendations(request,metadata) { const response = await recommendationsProvider.getRecommendations(request,metadata); }; ``` ### getRecommendations (with elevated permissions) ```javascript import { recommendationsProvider } from '@wix/ecom/service-plugins'; import { auth } from '@wix/essentials'; async function myGetRecommendationsMethod(request,metadata) { const elevatedGetRecommendations = auth.elevate(recommendationsProvider.getRecommendations); const response = await elevatedGetRecommendations(request,metadata); } ``` ### getRecommendations (self-hosted) Self-hosted 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 { recommendationsProvider } from '@wix/ecom/service-plugins'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { recommendationsProvider }, // Include the auth strategy and host as relevant }); async function getRecommendations(request,metadata) { const response = await myWixClient.recommendationsProvider.getRecommendations(request,metadata); }; ``` ---