API Gateway exposes Lambda, HTTP backends, and other AWS services as REST or HTTP APIs. It handles authentication, rate limiting, caching, and monitoring.
REST vs HTTP vs WebSocket
Feature
REST API
HTTP API
WebSocket API
Protocols
REST, OData
REST, gRPC
WebSocket
Auth
IAM, Cognito, Lambda
JWT, Lambda
Lambda
Rate limiting
Usage plans, API keys
Throttling per route
Connection limits
Caching
Yes
No
No
Cost
$3.50/million
$0.50-1.00/million
1.00/million+0.25/million connection-minutes
Use case
Full-featured API
Lightweight, modern
Real-time, chat, dashboards
REST API
Create API
# Create REST APIaws apigateway create-rest-api \ --name my-api \ --description "My REST API" \ --endpoint-types REGIONAL# Get API IDAPI_ID=$(aws apigateway get-rest-apis --query 'items[0].id' --output text)
REST API and HTTP API are different products — you CANNOT convert a REST API to HTTP API: They have different features, pricing, and architectures. If you start with REST and later want HTTP pricing, you must recreate the API.
API Gateway’s 29-second timeout applies to Lambda proxy integrations — for longer operations, use async invocation: If your Lambda takes > 29 seconds, API Gateway returns a 504. Use SQS to queue long tasks, or use HTTP APIs with Lambda async invocation.
HTTP API doesn’t support API keys or usage plans — if you need client identification, use REST API or Cognito: HTTP APIs are designed for service-to-service communication. They support JWT/Cognito but not API key authentication.
API Gateway caching is per stage — if you have multiple environments (dev/staging/prod) sharing the same API, caching affects all: Cache is keyed by route+query params, not by stage. If your API returns different data per user, enable authorization for cache control.
WebSocket connections stay open — each connection costs money even when idle:0.25/millionconnection−minutesmeans10Kalways−openconnectionscost180/month. Implement connection timeout/disconnect logic to avoid idle connection costs.