API Composition Pattern is a service that receives a request, then makes requests of multiple services, combines the results, and responds to the initiating request.
Use Case
Assume you have a task to develop where we want to pull data from 2 to 3 API services combine data and display it as output.
Let’s take an example where we want to display Account info, Vessel Details, and Purchase order Item details on the dashboard in this process we are going to call every single API get data from it, and bind details but what if we have many such apis which are pulling data on UI which will slow UI load time right.
In this process, we are going to call a single API and internally this API is going to call other 2 or 3 APIs depending upon how many services data you want to merge or combine and display at once.
Advantages
- Simple to implement this pattern
- Single point of contact
- hides complex implementation
Disadvantages
- If one of the APIs is consuming a lot of time then might affect performance.
- scaling might be a bottleneck
- data inconsistency
