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.
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());
}
}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?