What is the role of an API Gateway in microservices?

An API Gateway is the single entry point that sits in front of a microservices system, routing client requests to the right service and handling shared concerns for all of them.

Diagram: API Gateway routing client requests to microservices
API Gateway routing client requests to microservices

Key Points

Example

A mobile client sends every request to api.example.com, and the API Gateway forwards /orders/* to the Order service and /users/* to the User service, while enforcing a JWT check and a rate limit on every request before it's routed anywhere.

# Spring Cloud Gateway (application.yml): one entry point for all clients
spring:
  cloud:
    gateway:
      routes:
        - id: orders
          uri: lb://order-service          # load-balanced via service discovery
          predicates:
            - Path=/orders/**
        - id: users
          uri: lb://user-service
          predicates:
            - Path=/users/**
      default-filters:
        - AddResponseHeader=X-Gateway, api-gateway
  security:
    oauth2:
      resourceserver:
        jwt:
          issuer-uri: https://auth.example.com/realms/shop   # JWT checked once here

Interview Tip

A concise interview answer is

An API Gateway is the single front door to a microservices system: it routes requests to the right service and centralizes cross-cutting concerns like authentication, rate limiting, and TLS termination. It simplifies things for clients, who only need to know one endpoint, and keeps that shared logic out of every individual service.

Last updated: 11 November 2026

Previous question: What challenges might you face when working with microservices?

Next question: How does an API Gateway manage traffic?

More Microservices - Level I interview questions

All Microservices - Level I questions