What an API Gateway Does

Without an API gateway, each microservice is exposed directly to clients. Every service must implement auth, rate limiting, logging, and CORS. Clients must know every service's address. When service addresses change, clients break.

An API gateway centralises all of this:

  • Request routing: /api/users/* → User Service, /api/orders/* → Order Service
  • Authentication: Validate JWT/API key once at the gateway — services trust the gateway
  • Rate limiting: Enforce per-client request quotas before traffic reaches services
  • SSL termination: Handle HTTPS at the gateway — services communicate internally over HTTP
  • Request/response transformation: Translate between JSON and XML, add headers, reshape payloads
  • Load balancing: Distribute traffic across service instances
  • Logging & analytics: Capture all API traffic in one place
  • Caching: Cache responses for expensive or frequently-repeated calls

API Gateway vs Reverse Proxy vs Load Balancer

ComponentPrimary RoleAPI Awareness
Load BalancerDistribute traffic across server instancesNone — layer 4 (TCP) or basic layer 7
Reverse Proxy (Nginx)Forward requests, SSL termination, static filesMinimal — path-based routing only
API GatewayFull API management: auth, rate limiting, routing, transformFull — understands API semantics, keys, versions

Common API Gateway Features

Authentication & Authorisation

The gateway validates credentials centrally. Options: API key lookup, JWT signature verification, OAuth 2.0 token introspection. Once authenticated, the gateway passes the verified identity (user ID, roles) to downstream services as headers — services trust the gateway and never re-validate.

Rate Limiting

Common strategies: fixed window (100 req/min), sliding window, token bucket, leaky bucket. Rate limits can be applied per API key, per user, per IP, or per endpoint. When exceeded: return 429 with Retry-After and X-RateLimit-Remaining headers.

Request Aggregation

Instead of the client making 4 separate API calls to 4 services, the gateway makes them in parallel and returns a single aggregated response. Reduces client-side latency and network round trips — especially valuable for mobile clients.

Popular API Gateway Options

GatewayTypeBest For
AWS API GatewayManaged (AWS)Serverless/Lambda workloads on AWS
KongOpen-source / CloudComplex setups, rich plugin ecosystem
Nginx + pluginsSelf-hostedLightweight setups, existing Nginx users
TraefikOpen-sourceDocker/Kubernetes-native auto-discovery
Azure API ManagementManaged (Azure)Azure workloads, enterprise API management
Cloudflare WorkersEdge computeEdge routing + logic at CDN PoPs

💡 You Might Not Need One Yet

For a monolith or early-stage product, an API gateway adds unnecessary complexity. Start without one. Add it when you have multiple backend services that share auth/rate limiting concerns, or when you need a developer portal for external API consumers.

How We Research and Update This Guide

We test the underlying formula or workflow, compare outputs with reliable references, and revise examples whenever the page content changes.

  • The workflow or formula is tested directly in the tool and compared against independent reference examples.
  • Examples are kept practical so readers can verify the result without hidden assumptions.
  • Pages are revised whenever the interface, calculation flow, or surrounding guidance materially changes.

Frequently Asked Questions — API Gateway