Amazon Personalize
Developer Guide

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above.

GetRecommendations

Returns a list of recommended items. The required input depends on the recipe type used to create the solution backing the campaign, as follows:

  • RELATED_ITEMS - itemId required, userId not used

  • USER_PERSONALIZATION - itemId optional, userId required

Note

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

Request Syntax

POST /recommendations HTTP/1.1 Content-type: application/json { "campaignArn": "string", "itemId": "string", "numResults": number, "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: Yes

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

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" } ] }

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 ascending order by prediction score. There can be a maximum of 500 items in the list.

Type: Array of PredictedItem objects

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 AWS SDKs, see the following: