GetRecommendations - Amazon Personalize
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China.

GetRecommendations

Returns a list of recommended items. For campaigns, the campaign's Amazon Resource Name (ARN) is required and the required user and item input depends on the recipe type used to create the solution backing the campaign as follows:

  • USER_PERSONALIZATION - userId required, itemId not used

  • RELATED_ITEMS - itemId required, userId not used

Note

Campaigns that are backed by a solution created using a recipe of type PERSONALIZED_RANKING use the GetPersonalizedRanking API.

For recommenders, the recommender's ARN is required and the required item and user input depends on the use case (domain-based recipe) backing the recommender. For information on use case requirements see Choosing recommender use cases.

Request Syntax

POST /recommendations HTTP/1.1 Content-type: application/json { "campaignArn": "string", "context": { "string" : "string" }, "filterArn": "string", "filterValues": { "string" : "string" }, "itemId": "string", "numResults": number, "recommenderArn": "string", "userId": "string" }

URI Request Parameters

The request does not use any URI parameters.

Request Body

The request accepts the following data in JSON format.

campaignArn

The Amazon Resource Name (ARN) of the campaign to use for getting recommendations.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: No

context

The contextual metadata to use when getting recommendations. Contextual metadata includes any interaction information that might be relevant when getting a user's recommendations, such as the user's current location or device type.

Type: String to string map

Map Entries: Maximum number of 150 items.

Key Length Constraints: Maximum length of 150.

Key Pattern: [A-Za-z\d_]+

Value Length Constraints: Maximum length of 1000.

Required: No

filterArn

The ARN of the filter to apply to the returned recommendations. For more information, see Filtering Recommendations.

When using this parameter, be sure the filter resource is ACTIVE.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: No

filterValues

The values to use when filtering recommendations. For each placeholder parameter in your filter expression, provide the parameter name (in matching case) as a key and the filter value(s) as the corresponding value. Separate multiple values for one parameter with a comma.

For filter expressions that use an INCLUDE element to include items, you must provide values for all parameters that are defined in the expression. For filters with expressions that use an EXCLUDE element to exclude items, you can omit the filter-values.In this case, Amazon Personalize doesn't use that portion of the expression to filter recommendations.

For more information, see Filtering Recommendations.

Type: String to string map

Map Entries: Maximum number of 25 items.

Key Length Constraints: Maximum length of 50.

Key Pattern: [A-Za-z0-9_]+

Value Length Constraints: Maximum length of 1000.

Required: No

itemId

The item ID to provide recommendations for.

Required for RELATED_ITEMS recipe type.

Type: String

Length Constraints: Maximum length of 256.

Required: No

numResults

The number of results to return. The default is 25. The maximum is 500.

Type: Integer

Valid Range: Minimum value of 0.

Required: No

recommenderArn

The Amazon Resource Name (ARN) of the recommender to use to get recommendations. Provide a recommender ARN if you created a Domain dataset group with a recommender for a domain use case.

Type: String

Length Constraints: Maximum length of 256.

Pattern: arn:([a-z\d-]+):personalize:.*:.*:.+

Required: No

userId

The user ID to provide recommendations for.

Required for USER_PERSONALIZATION recipe type.

Type: String

Length Constraints: Maximum length of 256.

Required: No

Response Syntax

HTTP/1.1 200 Content-type: application/json { "itemList": [ { "itemId": "string", "score": number } ], "recommendationId": "string" }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

itemList

A list of recommendations sorted in descending order by prediction score. There can be a maximum of 500 items in the list.

Type: Array of PredictedItem objects

recommendationId

The ID of the recommendation.

Type: String

Errors

InvalidInputException

Provide a valid value for the field or parameter.

HTTP Status Code: 400

ResourceNotFoundException

The specified resource does not exist.

HTTP Status Code: 404

See Also

For more information about using this API in one of the language-specific Amazon SDKs, see the following: