Overview
During the course of design and implementation for API for modern API driven development, various engineers have been asking the gradually of API, how much responsibility each API shall have, and how to balance the initial implementation and ongoing maintenance of the APIs from both API provider and API consumer perspectives. In this post, I will be sharing my recommendations from my personal professional perspective, do let me know your view.
Technology has been evolving, eg from SOAP to RESTful, from monolithic application design to SOA and now MSA, however the underlying design principles remains unchanged, and we can still go back to the decades old design principles to guide modern application design, and API design specifically in this post.
One of the design principles I would like to reference here is the following para from "Basics of the Unix Philosophy"
"Make each program do one thing well. To do a new job, build afresh rather than complicate old programs by adding new features."
As this quote conveys, the Unix culture centers around small and simple tools that can be combined. This advice still rings true even after more than 45 years later when we deal with API design and development. To adapt this principle to API design, we may say, "Make each API do one thing well".
Benefits of making small functional APIs
So what's the benefits of adopting this API design principle, there are three benefits according to this books - Building Secure and Reliable Systems
- Design for Understandability.
- Design for Least Privilege
- Design for Resilience
Design for Understandability
It is much easier for API consumer to understand the API as it is small functional API, it has very specific functional responsibility, it has very specific input parameters and expected response. It is also easier to API provider to rollout new API faster and safer since it does not involve the changing of existing gigantic API
Design for Least Privilege
Design for Resilience