Services

Resources

Company

API gateway

An API gateway is a server that sits between clients and a set of backend services and acts as their single entry point. It routes each request to the right service and handles shared concerns in one place: authentication, rate limiting, TLS termination, request logging and sometimes combining several backend calls into one response.

How it works

Clients call one host, such as api.example.com. The gateway matches the path and method to a route: /orders goes to the orders service, /users to the users service. Before forwarding, it checks the API key or token and applies a limit, for example 100 requests per second per key. Over the limit, it returns HTTP 429 without touching the backend. A mobile home screen that needs data from 3 services can make 1 call to the gateway, which fans out and merges the replies.

Why it matters in production

Each service no longer has to rebuild auth, limits and logging, and the gateway is a natural place for metrics on every call. It is also on every request path, so it needs high availability, capacity headroom and careful change control. Business logic should stay out of it.

See also

On the One2N blog

Further reading

Four-panel comic about API gateway: Clients call ten services directly, and each service has its own auth and its own limits. Asha is lost; An API gateway becomes the one front door: it routes /orders and /users and checks every token; A key is allowed 100 requests per second. Request 101 gets...