1

Is there a way to "put events" using their REST API and not an SDK?

For example in their docs I see https://docs.aws.amazon.com/personalize/latest/dg/API_UBS_PutEvents.html

POST /events HTTP/1.1
Content-type: application/json

{
   "eventList": [ 
      { 
         "eventId": "string",
         "eventType": "string",
         "eventValue": number,
         "impression": [ "string" ],
         "itemId": "string",
         "properties": "string",
         "recommendationId": "string",
         "sentAt": number
      }
   ],
   "sessionId": "string",
   "trackingId": "string",
   "userId": "string"
}

But I've searched the docs everywhere for the base url and it does not seem listed at all.

Our problem is we need to log events to personalize both from iOS and web, and although there seems to be a js sdk, there does not seem to be an iOS sdk for personalize, so we were hoping to do it via simple REST calls.

Or would this be better do with a lambda function + api gateway?

fpghost
  • 2,834
  • 4
  • 32
  • 61
  • https://docs.aws.amazon.com/general/latest/gr/personalize.html - endpoints listed here. – Kisaragi Oct 05 '21 at 19:26
  • oh thanks, how did I miss that. Not sure if you want to add it as an answer and I'll accept or if my question should be deleted haha...but I was scouriong the personalize events docs and didn't realize the endpoint where listed elsewhere – fpghost Oct 05 '21 at 19:28

1 Answers1

1

Although you can make API calls directly to the service endpoints referenced in the comment by Kisaragi, you will have to sign your requests using SigV4 using your AWS access key and secret. The AWS language SDKs do this for you and AWS Amplify provides a AWS SDK for iOS and JavaScript. For JavaScript, there is an analytics provider for Personalize that can be used to send events from your web app directly to a Personalize event tracker. Amplify uses Amazon Cognito to make authenticated and unauthenticated calls so that brings in an additional dependency to consider.

An alternative approach, as you mentioned, would be to use Amazon API Gateway to create a public endpoint that both your iOS and web app can call using an authentication scheme of your choosing (JWT, IAM, Cognito, Lambda authorizer, etc). A Lambda function can be used to marshal events from API Gateway to a Personalize event tracker using the PutEvents API. Another common pattern is to have API Gateway send events to a Kinesis Data Stream and have your Lambda function consume events from Kinesis for Personalize as well as a Kinesis Data Firehose to send events to S3. This not only provides a more resilient decoupled architecture between your event producers (apps) and consumers (Personalize) but also allows you to more easily do more with your events such as clickstream analytics, replay events into another Personalize dataset group, etc. There is a deployable solution on the Amazon Personalize Samples GitHub repo that provides the API Gateway/Kinesis Data Stream/Kinesis Firehose to S3/Lambda to Personalize architecture.

James J
  • 621
  • 3
  • 6