Xoxoftware - XOXO Creative Studio | Web & Mobile App Development | Fred Cheung | Hong Kong
AWSMessaging

Amazon API Gateway

Managed API front door — create, publish, and secure REST, HTTP, and WebSocket APIs at any scale with throttling, caching, and authorization.

Overview

Amazon API Gateway is a fully managed service for creating, publishing, and managing APIs at any scale — it handles request routing, throttling, caching, authorization, and monitoring for REST, HTTP, and WebSocket APIs.


Core Concepts

ConceptDescription
REST APIFull-featured API type with resource-based routing, request validation, caching, and WAF integration
HTTP APILightweight, lower-cost API type optimised for Lambda and HTTP proxy integrations
WebSocket APIPersistent two-way communication for real-time applications (chat, streaming)
StageA named deployment snapshot (e.g., dev, staging, prod) with its own URL and settings
Resource & MethodURL path segments and HTTP verbs (GET, POST, etc.) that define API endpoints
IntegrationBackend target: Lambda, HTTP endpoint, AWS service, VPC Link, or Mock
AuthorizerAuthentication/authorization mechanism (Cognito, Lambda, IAM, JWT)
Usage PlanThrottling and quota limits applied per API key
API KeyToken distributed to consumers for usage tracking and quota enforcement

REST API vs HTTP API vs WebSocket API

FeatureREST APIHTTP APIWebSocket API
ProtocolREST (HTTP/1.1)HTTP (HTTP/1.1 + HTTP/2)WebSocket
PricingHigher (per million + cache)~70% cheaper than RESTPer message + connection mins
CachingYes (built-in)NoNo
Request validationYesNoNo
WAF integrationYesNoYes
Usage plans / API keysYesNo (use Lambda authorizer)No
Lambda authorizerYes (request + token)Yes (payload v2.0)Yes
JWT / Cognito authorizerVia Lambda authorizerYes (native JWT)No
IAM authorizationYesYesYes
VPC LinkYes (NLB)Yes (ALB, NLB, Cloud Map)No
Private endpointsYesNoNo

Integration Types

TypeDescription
Lambda ProxyPasses entire request to Lambda; Lambda controls the response format
Lambda Non-ProxyAPI Gateway transforms request/response using mapping templates
HTTP ProxyForwards request to an HTTP backend as-is
HTTP Non-ProxyApplies request/response transformations via mapping templates
AWS ServiceDirect integration with AWS APIs (e.g., SQS SendMessage, S3 PutObject)
MockReturns a static response without a backend — useful for testing
VPC LinkRoutes to private resources inside a VPC (via NLB or ALB)

Authorization Methods

Client Request
    → API Gateway
        ├── IAM (SigV4)           — for AWS-to-AWS / internal service calls
        ├── Cognito User Pool     — issues JWT; API Gateway validates natively (REST: via authorizer)
        ├── Lambda Authorizer     — custom auth logic (OAuth, SAML, tokens)
        └── API Key               — usage tracking + throttling (NOT authentication)

Exam Trap: API keys are for usage metering and throttling — they are NOT a security mechanism. Always combine API keys with an authorizer (IAM, Cognito, or Lambda).


Throttling and Caching

FeatureDetail
Default throttle10,000 requests/s account-wide; 5,000 burst
Stage-level throttleOverride per stage or per method
Usage plan quotaDaily/weekly/monthly request limits per API key
Caching (REST only)0.5 GB to 237 GB; TTL 0–3,600 s; reduces backend calls
Cache invalidationHeader Cache-Control: max-age=0 (requires authorization)

Common Use Cases

  • Serverless API backend — API Gateway + Lambda for fully managed request handling without servers.
  • Microservice API layer — Route requests to containers (ECS/EKS via VPC Link) with centralized auth and throttling.
  • Direct AWS service proxy — Expose SQS SendMessage or DynamoDB PutItem as an API without Lambda in between.
  • Real-time communication — WebSocket API for chat applications, live dashboards, or IoT command channels.
  • API monetisation — Usage plans + API keys to meter and throttle third-party developer access.

SAA/SAP Exam Tips

SAA Tip: "Serverless REST API" → API Gateway REST API + Lambda. "Cheapest serverless API" → API Gateway HTTP API + Lambda (HTTP API is ~70% cheaper).

SAA Tip: "Reduce Lambda invocations for repeated identical requests" → Enable API Gateway caching (REST API only). HTTP API does not support caching.

SAP Tip: For private APIs accessible only within a VPC, use REST API with a VPC Endpoint (Interface endpoint). HTTP APIs do not support private endpoints.


Cross-Cloud Equivalents

ProviderService / SolutionNotes
AWSAmazon API GatewayBaseline
AzureAzure API ManagementFull lifecycle management; developer portal
GCPGoogle Cloud API Gateway / ApigeeApigee for enterprise; API GW for serverless
On-PremisesKong, NGINX, Envoy, TykOpen-source API gateways

Pricing Model

DimensionUnitNotes
REST API requestsPer million requestsPlus cache instance cost if enabled
HTTP API requestsPer million requests~70% cheaper than REST; no caching charge
WebSocket messagesPer million messagesPlus connection minutes charged separately
WebSocket connection timePer million minutesCharged while client is connected

Built by Fred Cheung @CookedRicer · Powered by Fumadocs & Github Copilot

On this page