Skip to main content

Comparing HTTP and REST API Gateways

cloud aws devops api-gateway
Hugo
Author
Hugo
DevOps Engineer in London
Table of Contents

Main difference
#

RESTHTTP
Quota ManagementPer groupNot supported
API key ManagementSupportedNot supported
AuthorizationLambda/CognitoLambda/IAM/JWT
Lambda InputPayload onlyRequest details (Event)
VTL modelSupportedNot supported
SDK and Documentation GenerationSupportedNot supported

Lambda integration
#

Both REST and HTTP Lambda integrations offer a powerful and flexible way to integrate Lambda functions with API Gateway, with some differences in input/output format and response handling.

Input / Output Format
#

  • Lambda Proxy Integration in REST and Lambda Integration in HTTP both pass the request information to the event object in the Lambda function. However, the input and output format are different.
  • In HTTP APIs, if the Lambda function returns valid JSON and doesn’t return a statusCode or a string, API Gateway assumes that the result is the body of the response. In REST APIs, the Lambda function has to construct the response object with the appropriate status code, headers, and body. This is not possible in HTTP APIs.

VTL
#

  • In REST APIs, the Lambda function can use VTL templates to transform the response data. VTL templates allow for specifying how the response data should be transformed from one format to another.
  • In HTTP APIs, only JSON data is supported and response transformation using VTL templates is not possible.

* The VTL is used in REST APIs for the following:

  • Request & Response Validation
  • Generate an SDK
  • Initialize a mapping template

Data Transformations
#

Integration TypePath/ Query/ HeaderMapping Template
lambdaN/AY
lambda proxyNN
httpYY
http proxyYY

Data that Backend Receives
#

Integration TypePathQueryHeadersPayload
lambdaNNNY
lambda proxyYYYY
httpYYYY
http proxyYYYY