Glossary

What is API composition?

API composition is a pattern in which one API operation calls several underlying services or systems and combines their results into a single response. The consumer makes one request, and the composer handles the order of calls, the joining of data, and what to return if a dependency fails.

In more detail

Where the pattern comes from.

The pattern is best known from microservices design, where data that used to sit in one database is split across services and a query has to gather it again. A composer, sometimes an API gateway and sometimes a dedicated service, calls each owner of the data and joins the results in memory. The same idea applies to enterprise systems, where one business answer may need an ERP, a CRM, and a logistics platform. The hard parts are the same in both: latency, partial failure, and consistency between sources read at slightly different times.

Example

An example: an order summary.

  1. 01

    One request

    A consumer asks for an order summary by order identifier.

  2. 02

    Several calls

    The composer reads the order from order management, then reads fulfilment and carrier status in parallel.

  3. 03

    One response

    It returns a single result. If the carrier does not answer in time, it returns the rest and marks the delivery part as unavailable.

Related terms

How it differs from related terms.

CQRS and materialized views

Instead of composing at request time, a system can keep a precomputed read model that is updated as events arrive. Reads are faster and survive a source outage, at the cost of maintaining a copy.

Backend-for-frontend

A backend-for-frontend composes calls for one application's screens. A composed API built for reuse serves several consumers.

Orchestration and choreography

Orchestration means a central coordinator directs the calls, as an API composer does. Choreography means services react to each other's events with no coordinator.

Questions

Questions about API composition

What are the drawbacks of API composition?
Response time depends on the slowest dependency, availability depends on all of them, and data read from several sources may not be consistent to the same instant.
When should a precomputed view be used instead?
When queries are heavy or frequent, when they filter or sort across sources, or when the answer must be available while a source is down.
Can a composed API write to several systems?
It can, but systems rarely share a transaction. A write across several of them needs compensation steps for the case where one succeeds and another fails.

Map where these terms apply in your own integration landscape.