What is the API Gateway pattern, and why is it important in a microservices architecture?

The API Gateway pattern provides a single entry point that sits in front of a microservices system, routing and managing all client requests instead of exposing every service directly to clients.

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

Key Points

Example

A single-page web app calls api.example.com/dashboard, and the API Gateway internally fetches data from the Orders, Profile, and Notifications services, combines it into one response, and enforces authentication before any of those calls happen.

// API composition in a gateway or BFF: one client call, three services
// called in parallel, one combined response
@RestController
public class DashboardController {

    @GetMapping("/dashboard/{userId}")
    public Dashboard dashboard(@PathVariable String userId) {
        CompletableFuture<Profile> profile =
                CompletableFuture.supplyAsync(() -> profileClient.get(userId));
        CompletableFuture<List<Order>> orders =
                CompletableFuture.supplyAsync(() -> orderClient.recent(userId));
        CompletableFuture<Integer> unread =
                CompletableFuture.supplyAsync(() -> notificationClient.unreadCount(userId));

        return new Dashboard(profile.join(), orders.join(), unread.join());
    }
}

Interview Tip

A concise interview answer is

The API Gateway pattern gives clients one entry point instead of talking to every microservice directly. It's important because it centralizes routing, security, and rate limiting in one place, and can aggregate multiple backend calls into a single response, which keeps client code simple even as the number of services grows.

Last updated: 11 November 2026

Next question: How does an API Gateway improve security and performance in a microservices system?

More Microservices Design Patterns interview questions

All Microservices Design Patterns questions