What is the API composition pattern and when would you reach for it?
API composition is a pattern where one component — often built into an API gateway or a dedicated backend-for-frontend service — receives a single incoming request, calls each of the individual microservices that owns a relevant piece of data, waits for all of their responses, and merges them into one combined response for the client. It's the right first choice for any read that needs data from a small number of services (roughly two to four) and doesn't require complex cross-service sorting, filtering, or extremely low latency. It keeps every individual service simple, since none of them needs to know the others exist — all of the cross-service awareness lives in exactly one place, the composer.
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response