API driven application Vs API Drive business
Micro service based application is the new trend now. The foundation of this architecture is the capability of the various application (aka micro services) to communicate among themselves through REST APIs. The single responsibility principle based micro services communicate with each other using APIs to complete an end user/client workflow. With multiple ways to connect to the system and with same REST API based communication capabilities of various external systems, the type of clients which can access the application is also increasing day by day. Gone were the days when the most important client for any web application was a browser sitting on one’s system. In today world, apart from other physical devices like mobile, client can be anyone who can call these APIs over a network protocol.
So what is the difference between the APIs which is driving the application (inter communication between various micro service) vs the API which a client/consumer can call (business oriented)?
Normally the API between the micro service can be at a very granular level. Considering a simple application of seller which has 3 basic micro services, user data management, Production management & order management with an UI service
An order workflow may need to talk to all the three services, first to get the user details, then the product details and then place an order. Workflow can be more complex then this where it may have to call multiple API of same service as part of it. In our simple example at least 1 API each need to be called to complete the order placement. This order of API is managed by the UI service.
With time, few more consumers become a reality and like to make the same order workflow through an API. At present there is no single API which can do the job for it. It need to maintain the same sequence of 3 API calls to compete it. This actually mean that each client which want to place an order need to make these API calls in a particular order. Any change to this may result in change in every client.
This bring up the need of APIs which are driven by business, where a high level API is written which encapsulate the order of these calls and exposes it to external world.
So application driven API can be at a granular level and small in nature and may be fulfilling a single need of data while a business driven API is a workflow encapsulating these small API with a logic to complete a business workflow.
The Business API interface is nothing but a gateway here which build the same workflow at its level with smaller APIs and expose it to external world. Any change in the API or addition of extra logic/API will bring the change at the gateway level only which the external client will continue to use the encapsulated and exposed API only. Please note that this also bring in the security for application API as we don’t need to expose them externally individually.
At another thought, it may also look relevant that why not UI service also consumer the business API instead of application level, however please note that UI may have to show the data related to user, product and past orders on UI and need the data from those small API Still. The business gateway only fulfills those consumers which want to make a workflow call through an API. The security setup for internal APIs and business API will also be difference as they are expose to different network all together (private vs public network)