Learn how to make Recommendations API requests to retrieve recommendation data generated from recommendation configurations:
See also Recommendations API: Responses (configurations).
If you want to retrieve recommendation data generated from recommendation strategies, see Recommendations API: Requests (strategies).
URL
The URL for Recommendations API requests is https://<platform_instance>/recoApi/v2
, where <platform_instance>
is the domain name of your Frosmo Platform instance.
To get the URL for your Frosmo Platform instance:
- In the Frosmo Control Panel, select Utilities > Frosmo APIs.
In the Recommendations API section, copy the URL.
Authentication
The Recommendations API does not require authentication.
Methods
The Recommendations API supports the following HTTP methods for recommendation configurations:
- GET
- POST
The only difference between the two is that with GET you provide the recommendation details in the request URL, while with POST you provide the details in the request body. If you're retrieving data for a recommendation configuration with a GET request, and the request URL exceeds the maximum URL length, use a POST request instead.
Syntax
GET
To retrieve recommendation data for a recommendation configuration using the GET method, make the following request:
GET https://<platform_instance>/recoApi/v2?method=multifetch& origin=<site_origin>& recos=[{ "name": "<recommendation_configuration_name>", "params": { "<parameter_1_name>": "<parameter_1_value>", "<parameter_n_name>": "<parameter_n_value>" } }]
POST
To retrieve recommendation data for a recommendation configuration using the POST method, make the following request:
POST https://<platform_instance>/recoApi/v2?method=multifetch& origin=<site_origin> # REQUEST BODY [{ "name": "<recommendation_configuration_name>", "params": { "<parameter_1_name>": "<parameter_1_value>", "<parameter_n_name>": "<parameter_n_value>" } }]
Parameters
Table: Query parameters for Recommendations API requests
Parameter | Description | Type | Role | Example |
---|---|---|---|---|
method | Request type. Use the value | String | Required | method=multifetch |
origin | Site origin. To find out your site's origin, see Getting your site origin. | String | Required | origin=shop_company_com |
recos | Information about what recommendation data to retrieve and, if appropriate, how to filter the returned data with parameters defined in the recommendation configuration. You can retrieve the data for one or more recommendation configurations. You specify each configuration in its own recommendation configuration settings object using the JSON format. The array must not be empty ( If you want to guarantee a fast response, limit the number of recommendations to four. You can retrieve the data for five or more recommendations in the same request, if you want, but the platform may then take longer to respond. The | Array of recommendation configuration settings objects | Required (GET) | Retrieve the data for one recommendation configuration: recos=[{ "name": "Most viewed products", "params": { "type": "Books" } }] Retrieve the data for two recommendation configurations: recos=[{ "name": "Most viewed products", "params": { "type": "Books" } },{ "name": "Products viewed together", "params": { "id": "123" } }] |
debug | Define whether to return debugging information about the recommendation data. The debugging information for a recommendation consists of:
The possible values are:
The default value is | Boolean | Optional | debug=true |
Recommendation configuration settings object
The following table describes the recommendation configuration settings object of the recos
array. The object defines what recommendation data to retrieve and, if appropriate, how to filter the returned data.
Table: Recommendation configuration settings object properties
Property | Description | Type | Role | Example |
---|---|---|---|---|
name | Recommendation configuration name. | String | Required | "name": "Most viewed products" |
params | Request parameters defined in the recommendation configuration. Use the parameters to filter which recommended items to return. You can only include parameters defined in the recommendation configuration:
If the recommendation type is If the recommendation type is If you do not want to use any parameters to filter the recommendation results, omit this property from the request. | Object | Optional | For a "params": { "id": "123" } For a "params": { "type": "Books" } For a # Filter by type and language. "params": { "type": "Books", "language": "English" } # Filter by type only. "params": { "type": "Books", "language": "" } # Filter by neither, return all results. "params": { "type": "", "language": "" } # Omitting "params" from the request yields the same result as the empty values above. |
params.<parameter_name> | Request parameter defined in the recommendation configuration. Use the parameter to filter which recommended items to return. You can define either a single string or an array of strings as the parameter value. In the latter case, the recommendation results are filtered separately by each string value. If the parameter corresponds to a source data field that has a Boolean or number value, such as product price, define the parameter value nonetheless as a string. For example, define the Boolean If you do not want to filter the results by the parameter, set the parameter value to an empty string ( | String | Array of strings | Required | Filter for "params": { "type": "Books", "language": "English" } Filter for "params": { "type": "Books", "language": [ "English", "Finnish" ] } Filter for "params": { "type": [ "Books", "Magazines" ], "language": [ "English", "Finnish" ] } Filter by originally boolean and numeric values: "params": { "isAvailable": "true", "price": "99.99" } No filtering: "params": { "type": "", "language": "" } |
excludeIds | This property is only valid for product recommendations. IDs of the products to exclude from the recommendation data. | Array of strings | Optional | Exclude products "excludeIds": [ "123", "456", "789" ] |
limit | Maximum number of recommended items to return. By default, the platform uses the The minimum value is | Number | Optional | "limit": 5 |
mapping | Logic for mapping the IDs of the recommended items to source data in the Frosmo back end. This determines what data the recommendation actually returns for each item. By default, the platform uses the The possible values are:
| String | Optional | "mapping": "" |