An API gateway is a server that acts as a single entry point for all client requests in a microservices architecture. It handles request routing, authentication, rate limiting, load balancing, and API composition.
In a microservices architecture, clients would otherwise need to know the address of every service. The API gateway sits between clients and services, providing a unified API surface. It routes requests to appropriate services, handles cross-cutting concerns (auth, logging, rate limiting), and can aggregate responses from multiple services.
The client sends a request to the API gateway (e.g., POST /api/orders). The gateway authenticates the request, checks rate limits, then routes it to the order service. It can also fan out requests to multiple services (e.g., fetch user + order + product data) and aggregate the results into a single response. Popular gateway implementations include Kong, AWS API Gateway, and NGINX.
An API gateway is a specialized reverse proxy that also handles cross-cutting concerns like auth, rate limiting, and API versioning. NGINX is a reverse proxy that can be configured as an API gateway.
For small projects with 1-3 services, probably not. For microservices with 5+ services, an API gateway simplifies client code and centralizes cross-cutting concerns like authentication and monitoring.