← Blog

AWS API Gateway: What It Is and When to Use It

2026-09-07 · 5 min read · SubToAPI Team

What AWS API Gateway Actually Does

AWS API Gateway is a managed service for creating, publishing, and securing HTTP APIs without running your own reverse proxy or load balancer. It sits in front of backend compute — usually Lambda, but also EC2, ECS, or any HTTP endpoint — and handles routing, authentication, throttling, request/response transformation, and usage metering.

The core reason teams reach for it: you don't want to run and patch an Nginx or Kong instance, manage TLS certificates, or write your own rate-limiting logic. AWS handles scaling, availability, and the undifferentiated plumbing, and you pay per request instead of for idle servers.

REST API vs HTTP API vs WebSocket API

AWS API Gateway isn't one product — it's three API types under one console, and picking the wrong one is the most common early mistake.

If you're building a typical backend-for-frontend or public API, start with an HTTP API and only move to REST if you hit a feature gap.

When You Need AWS API Gateway

It's a strong fit when:

When to Skip It

API Gateway adds latency (typically single-digit to low double-digit milliseconds per hop) and a per-request cost that adds up at high volume. It's also easy to over-engineer:

Setting Up a Basic AWS API Gateway

A minimal HTTP API in front of a Lambda function looks like this using the AWS CLI:

# create the HTTP API
aws apigatewayv2 create-api \
  --name "my-service-api" \
  --protocol-type HTTP \
  --target arn:aws:lambda:eu-west-1:123456789012:function:my-function

For anything beyond a single-route proxy, you'll typically:

  1. Create the API and a default stage (or use $default for auto-deploy).
  2. Add routes (GET /items, POST /items/{id}) mapped to Lambda integrations.
  3. Attach a JWT or Lambda authorizer for auth.
  4. Configure throttling limits (burst and steady-state rate) per stage or per route.
  5. Enable access logging to CloudWatch for debugging and audit trails.

Once deployed, a route is callable directly:

curl https://abc123.execute-api.eu-west-1.amazonaws.com/items/42

The setup is straightforward for a handful of routes but grows in complexity fast once you add custom domains, request validation, canary deployments, and per-client rate limits — at which point Infrastructure-as-Code (CDK, Terraform, SAM) becomes necessary rather than optional.

AWS API Gateway Pricing, Briefly

Pricing is usage-based: you pay per million API calls, plus data transfer out, and (for REST APIs) an additional charge for caching if enabled. HTTP APIs are cheaper per request than REST APIs. There's no charge for idle time — if nobody calls your API, you pay nothing beyond storage for logs. This makes it attractive for low-traffic or spiky internal tools, and less attractive at very high, steady request volumes where a load balancer plus fixed compute can end up cheaper.

Always model cost against your actual request volume and payload size before committing — the per-request math changes meaning depending on whether you're serving a handful of internal services or a public API with millions of daily calls.

Alternatives Worth Considering

Choosing the Right Tool

AWS API Gateway is the right default when you're already on AWS, your backend is Lambda-based, and you need standard REST/HTTP routing with authentication and throttling. It's the wrong tool when your actual need is narrower — like exposing a single AI provider behind API keys with usage tracking — because you end up rebuilding metering, key issuance, and streaming support that a focused product already ships.

FAQ

Is AWS API Gateway the same as an API management platform like Apigee? No. API Gateway handles routing, auth, and throttling for your own backend. Full API management platforms add developer portals, monetization, and analytics on top — features you'd need to build separately on AWS.

Does AWS API Gateway support streaming responses? HTTP APIs support response streaming in limited cases, but there are payload size and timeout constraints that make it a poor fit for long-lived token-by-token streaming, such as LLM output. Purpose-built API layers handle this more directly — see /docs/streaming for an example.

Can I use AWS API Gateway without Lambda? Yes. It can proxy to any HTTP backend — EC2, ECS, on-premises servers via VPC Link, or third-party APIs — Lambda is just the most common integration, not a requirement.

Turn your Claude access into an HTTPS API

SubToAPI gives you application API keys, streaming, tool use and usage insights on top of your existing Claude access — set up in minutes.

Start free  Read the quickstart →