← Back to microservices patterns map
🔀
Microservices Pattern

API Composition

Aggregate data from multiple services into one response.

query

Detailed Description

API composition is useful when a client needs data owned by multiple services.

Protect it with timeouts, partial responses, caching, and careful fan-out limits.

Visual Diagram

Composition Flow
  Client: GET /order-summary/456
                ↓
  [OrderComposer]
     ↓ parallel calls:
     → UserService.getUser(orderId.userId)
     → OrderService.getOrder(456)
     → ProductService.getProducts(orderItems)
     ← merge all responses
  return combined OrderSummary to client

Tradeoffs

Pros

Simple for clients, no shared database

Cons

Can create latency fan-out

Examples: GraphQL resolvers, BFF aggregators