The Comprehensive Guide to REST API Architecture and Conventions
Best Practices for Path Structure, Versioning, and Error Handling

A lifelong learner. Love to travel. Listen to music.
Search for a command to run...
Best Practices for Path Structure, Versioning, and Error Handling

A lifelong learner. Love to travel. Listen to music.
No comments yet. Be the first to comment.
Understanding the Performance Implications of async and defer Attributes

Overview static: Default position. It does not allow setting properties like top, bottom, left, right, z-index relative: Acts the same as static. but allows positioning it relatively by putting properties like top, bottom, left, right, z-index absolu...

Overview When an element in the browser has a conflict of styles, the browser uses a set of rules to determine which style should be rendered. This set of rules is defined as CSS Selector Specificity. For instance, for an element, if we have the foll...

Master block, inline, flex, and grid to build better web layouts

Consider that we are interacting with multiple entities. We should build the API path as follows,
domain + /API + /Version + /Entity + /ID Parameter [Optional] + /SubEntity + /ID Parameter + ? + fromDate=01/02/2022 + & + endDate=02/02/2022
For instance, if we want to get all the items of an order, where the order ID is 17, out API should look like this,
https://mydomain/api/v1/order/17/items
Let’s debug the previous URL step by step,
Few conventions,
The api keyword should be somewhere as follows
api.mydomain.com [Preferred]
API should support versioning,
Inside request header [Preferred]
Inside URL. In this case,
Version starts after the api/
Version should have a prefix v
Version number should be a natural number, like 1, 2, 3, etc. No decimal should be used
Should not put versioning in the query parameters
The entity should be one word as a name, but not a verb, since the HTTP method is taking care of that
ID Parameter: The ID parameter should come after the entity
Subentity: The subentity should come after the entity
Query Parameters: Should come after ? and concatenated by the &
While nothing was found in query parameters, it’s fine. However, missing ID parameters should throw an error.
For an entity, there could be multiple query parameters. But there should be only one ID parameter for the entity.
To extend, query parameters may return one to multiple entities, but if the ID parameter finds nothing, it will throw an error.
Five Groups
1xx: Avoid this one, for informational purposes
2xx: Success
3xx: Avoid this one, Redirection in OS low-level
4xx: Client Error
5xx: Server Error
200 - Ok: Default Status Code
Get request, get data
Post request created data
201 - Created: On Post request, entity created
202 - Accepted: Request accepted and under processing on the server
204 - No Content: Operation completed and no entity as response
400 - Bad Request: Client sent a request with invalid parameters or JSON
401 - Unauthorized: Server does not recognize the client
403 - Forbidden: Server recognizes the client, but the client does not have enough permission to access the resource
404 - Page Not Found:
The resource entity was not found.
Entity with the ID parameter not found
Not Applicable when query parameters are used
JWT Token should be passed using Authorization Header with a prefix bearer
To keep up the scalability and availability,
Using an asynchronous mechanism for long-term operation
Using caching for near-frequently accessed data with expiration
Use a rate limit to reduce the maximum concurrent requests
Rate limit for a specific user
Request/sec
Failure ratio
Latency between request and response
Memory, CPU Utilization
Users, sessions, geolocation distribution
Stands for, Hypermedia as the Engine of Application State. The user should not have prior knowledge of resources. Other relevant resource links should be included in the response.
If the URL of one service is changed, all other services calling that service will go down. To resolve this, we can use Yellow Page Directories, where the service and mapping will be stored. Also, it is possible to use an Gateway as a middleman, it will handle the URL mapping of a specific service.