Mithun Manohar
Mithun Manohar

Reputation: 586

How to expose AWS Personlize recommendations via REST API

I want to expose the recommendations from AWS Personalize to clients via REST API. At this point I am thinking about AWS API Gateway > AWS Lambda > AWS Personalise. Is there a native way to do this or a better approach to do this?

Upvotes: 0

Views: 814

Answers (1)

James J
James J

Reputation: 731

Using API Gateway and a Lambda function is one of the more common ways of creating a REST API around a Personalize campaign. API Gateway gives you the ability to add caching, throttling, alternative security patterns, and more. Since the Personalize GetRecommendations/GetPersonalizedRanking APIs only return itemIds and scores, you typically want to decorate the itemIds with the item metadata needed by clients to render recommendations (e.g., item price, name, description, image URL, etc). Otherwise your clients will likely have to lookup that information elsewhere. The Lambda function gives you the layer needed to lookup item metadata from your item catalog and return a response more suitable for rendering in an application. The Amazon Personalize Samples GitHub repo has an example using SAM to deploy Lambda functions for providing recommendations and ingesting events behind API Gateway.

Some other options include AWS App Runner which supports deploying code from a GitHub repo or a Docker container image from ECR behind an auto-scaling API or a microservice in ECS/EKS behind an Application Load Balancer. An alternative to REST is a GraphQL endpoint using AWS AppSync with a Lambda function as described above.

The best option comes down to the approach that best suits your existing architecture or experience.

Upvotes: 2

Related Questions