This blog is all about introduction to RESTful API design, it gives idea about What, Why and How of the same.
HTTP is expressive, ubiquitious and powerful.
API design is complex, a game of trade offs.
STEPS OF DESIGNING API
- Decide what functionalities to expose,
- Then how to expose,
- What to expose and,
- Adjust and improve according to use cases
- Rethink and improve
Consider a coffee cup, you can't hold a cup filled with hot coffee. There we need a handle, this helps you to hold the cup, also it allows you to hang it somewhere. Hence the handle serves for more than one purpose.
Similar to this, API has more than on use cases and functionalities.
Scenarios where we need API
Bolt on strategy - Add API to existing functional system, it is a brute force approach, but not very efficient.
Greenfield Strategy - No underlying application, do whatever you want, in way you want, you start from scratch, requires massive investment
Facade strategy
Take advantage of existing business systems, replace piece by piece.
Good modelling of an API
- Don't worry about the tools (keep and take notes)
- Have a consistent process (document things nicely)
- It does not count unless its written down Documentation is non negotiable
Steps of designing an API
- Identify participants (takes or receives action)
- Identify Activities
- Break into steps
- Create API definitions
- Validate API
HTTP VERBS
- GET - to retrieve data
- DELETE - delete data
- PUT - Update existing record
- POST - create new records
API Relationships
- Independent : can exist on its own without any resources
- Dependent : can only exist if other resource exists
- Associative : can be dependent or independent but needs additional information to describe it
Validate an API
- Step through each API call
- Write code as if an API call exist (Use a microservices) (List endpoints, parameters)
- Look for gaps and potential issues
Thanks for reading <3
Top comments (0)