Amazon API Gateway is a fully managed AWS service for creating, publishing, securing and operating HTTP, REST and WebSocket APIs at any scale. In serverless architectures within the Cloud, it acts as the front door that accepts client requests, authenticates them, applies throttling and transformation rules, and forwards them to a backend such as AWS Lambda, a container service, another AWS service or any public HTTP endpoint.
Because the service is billed per request and scales without capacity planning, it pairs naturally with function-based backends: an application can expose dozens of endpoints without running a single server or load balancer, and the cost falls close to zero when traffic stops.
How Amazon API Gateway processes a request
Amazon API Gateway processes each call through a fixed request pipeline that runs before and after the backend is reached. A client sends an HTTPS request to a stage endpoint, the gateway matches it to a resource and method (or a route in HTTP APIs), runs authorization, validates and optionally transforms the payload, and then invokes the configured integration.
The response travels back through the same pipeline, where the gateway can map status codes, rewrite headers and cache the result. The main stages of this flow are summarized below.
| Stage | What happens | Typical configuration |
|---|---|---|
| Endpoint and routing | Request is matched to a route or resource and method | Path such as /orders/{id} with GET |
| Authorization | Caller identity is verified | IAM, Cognito user pool, JWT or Lambda authorizer |
| Throttling and quotas | Rate and burst limits are enforced | Account, stage, method or usage plan limits |
| Request validation | Body and parameters are checked | JSON Schema models, required headers |
| Integration | Backend is invoked | Lambda proxy, HTTP proxy, AWS service, mock |
| Response mapping | Output is shaped and optionally cached | Mapping templates, cache TTL |
Two integration styles dominate. In a proxy integration, the gateway passes the entire request to the backend and returns its response unchanged, which keeps logic in code. In a non-proxy integration, Velocity Template Language mapping templates reshape requests and responses inside the gateway, which allows direct calls to services such as DynamoDB or Step Functions without any intermediate function.
API types: REST, HTTP and WebSocket
Amazon API Gateway offers three API types that differ in features, latency and price, and choosing among them is the first design decision. REST APIs are the original, feature-rich option; HTTP APIs are a leaner, cheaper and lower-latency product; WebSocket APIs maintain persistent two-way connections for real-time messaging.
| Capability | REST API | HTTP API | WebSocket API |
|---|---|---|---|
| Relative price per million requests | Highest | Roughly 70 percent lower | Billed per message and connection minute |
| Usage plans and API keys | Yes | No | No |
| Response caching | Yes | No | No |
| Request validation and transformation | Full mapping templates | Limited parameter mapping | Route selection expressions |
| Native JWT authorizer | Through Cognito or Lambda | Yes | Through Lambda |
| Private endpoint type | Yes | No | No |
| Typical use | Public or partner APIs with governance | Simple Lambda or container backends | Chat, live dashboards, notifications |
REST APIs also come in three endpoint types: edge-optimized, which routes traffic through the CloudFront network for geographically spread clients; regional, which serves clients in the same region or behind a custom CDN; and private, which is reachable only from inside a VPC through an interface endpoint.
Security, throttling and operational limits
Security in Amazon API Gateway rests on layered controls: authentication at the gateway, network restrictions through resource policies and optional AWS WAF rules, and encryption in transit through TLS. Mutual TLS can be required on custom domain names when clients present certificates.
Throttling uses a token bucket algorithm with a steady-state rate and a burst capacity. By default, an account receives about 10,000 requests per second with a burst of 5,000 per region, although these defaults can be raised on request and vary by region. Exceeding a limit returns HTTP 429 Too Many Requests, which clients should handle with exponential backoff.
Several hard or soft limits shape architecture decisions and are often discovered late in a project.
| Limit | Typical value | Design consequence |
|---|---|---|
| Integration timeout | 29 seconds by default | Long jobs need asynchronous patterns |
| Payload size | 10 MB per request | Large uploads should use presigned S3 URLs |
| WebSocket message frame | 32 KB per frame | Large messages must be split |
| WebSocket connection duration | 2 hours maximum | Clients must reconnect periodically |
| Cache size | 0.5 GB to 237 GB | Chosen per stage; billed hourly |
How it relates to neighboring serverless services
Amazon API Gateway is an ingress and API management layer, not a compute service, so it is usually combined with others rather than compared directly. Its closest alternatives are other ways of exposing an HTTP endpoint for a function or container.
| Option | Strength | Weakness |
|---|---|---|
| Amazon API Gateway | Authorization, throttling, keys, transformation | Per-request cost, 29-second default timeout |
| Lambda function URL | Simplest single endpoint, no extra charge | No usage plans, caching or routing |
| Application Load Balancer | Cheaper at sustained high traffic | Hourly charge even when idle, fewer API features |
| Amazon CloudFront with Lambda@Edge | Global edge execution | Restricted runtime and payload limits |
Event-driven designs often place the gateway at the edge and hand off work to Amazon EventBridge, SQS or Step Functions, so that the client receives a quick acknowledgment while processing continues asynchronously. Infrastructure is commonly defined with AWS SAM, the Serverless Framework or CloudFormation, which keeps routes, authorizers and stages under version control.
Common mistakes and how to avoid them
Most production incidents with Amazon API Gateway come from misread limits and missing observability, not from the service itself. The following list collects frequent errors seen in practice.
- Choosing REST APIs by habit when an HTTP API covers every requirement at a fraction of the cost.
- Running synchronous long tasks that exceed the integration timeout instead of returning a job identifier.
- Treating API keys as authentication; they identify usage plan customers but do not prove identity.
- Ignoring cold start latency of Lambda backends; provisioned concurrency or lighter runtimes help latency-sensitive routes.
- Leaving access logging disabled, which makes 4xx and 5xx spikes hard to diagnose; structured logs and CloudWatch metrics such as Latency and IntegrationLatency should be enabled per stage.
Explained without jargon
Think of Amazon API Gateway as the reception desk of an office building. Visitors, which are apps and websites, arrive with requests. The desk checks who they are, refuses anyone without a valid badge, limits how many people come in at once, and sends each visitor to the right department.
The departments behind the desk can be small programs that start only when needed. Because the desk is run by Amazon, the business never hires staff for it or worries about crowds. It pays only for the visitors who actually come in.
A typical use case
A regional food delivery startup builds its mobile ordering backend on AWS. The team creates an HTTP API with routes such as POST /orders and GET /orders/{id}, uses a JWT authorizer connected to its Cognito user pool, and sends each route to a separate Lambda function written in Python.
Placing an order writes to DynamoDB and publishes an event to EventBridge, which triggers restaurant notification and courier assignment asynchronously, so the API responds in about 150 milliseconds. A stage throttle of 200 requests per second protects the database during lunch peaks.
With roughly 3 million requests per month, the gateway costs only a few dollars, there are no servers to patch, and traffic that triples on holidays is absorbed without any capacity changes.