REST API Integration with Comprehend

Understand REST API integration with Amazon Comprehend.

AWS Comprehend

AWS has a range of AI-enabled services. Comprehend is one of them. It provides easy access to several NLP services like keyword detection, sentiment analysis, and many more. It has built-in API models trained by AWS. That way, we can access high-class AI models without going through the tedious task of training them.

We can use AWS API Gateway to access this service and build a custom API with NLP-enabled functionality. Let's learn how.

Implementation

The Comprehend APIs are POST, requiring the data in the request body. The URL is constant: https://comprehend.us-east-1.amazonaws.com. The action is carried in the request header. The Comprehend API documentation details the exact content of this payload for the API.

In our example, we implement NLP entity detection using the DetectEntities API. This API’s payload request body is forwarded as is from the API request. The response is also relayed untouched. The important part of this integration is the custom header field.

Check out the code below.

Get hands-on with 1200+ tech skills courses.