Use descriptive and meaningful resource names-
Instead of generic or ambiguous names, choose resource names that accurately represent the entities they represent.
Use HTTP methods correctly-
Use the appropriate HTTP methods (GET, POST, PUT, DELETE, PATCH, etc.) for different operations.
Version your APIs-
Use versioning to ensure backward compatibility and allow for future enhancements without breaking existing clients.
Use HTTP status codes correctly-
Return the appropriate HTTP status codes to indicate the success or failure of an API request.
Pick your JSON field naming convention (and stick to it)-
JSON standard doesn’t impose a field naming convention, but it’s a best practice to pick one and stick with it.
Use consistent error messages-
In most cases, HTTP status codes are not enough to explain what went wrong.
To help your API consumers, include a structured JSON error message.
The response should include the following information-
Use query parameters for filtering, sorting, and searching-
Query parameters allow you to provide additional information in the URL of an HTTP request to control the response returned by the server.
Implement authentication and authorization-
Secure your APIs by implementing proper authentication and authorization mechanisms.
=>USE API KEYS, TOKENS, OR OAUTH 2.0 FOR AUTHENTICATION
=>APPLY ROLE-BASED ACCESS CONTROL (RBAC) FOR AUTHORIZATION
A REST API should not maintain a state on the server. That’s the responsibility of the client.
This is important because it allows for the API to be cacheable, scalable, and decoupled from the client.
For example, an e-commerce API might use cookies to maintain the state of a shopping cart. However, such an approach violates key the key principle of RESTful APIs — they need to be stateless.