/
Must known design principles for REST API
Use HTTP methods correctly
- GET : Retrieve data from the server.
- POST : Send data to the server.
- PUT : Update data to the server.
- PATCH : Partially update data to the server.
- DELETE : Delete data from the server.
Use Nouns for resources
Use plural nouns for resources and avoid verbs in the URL/URI.
Good practice : /customers
Bad practice : /getCustomers
Use appropriate status codes
- 200 OK : Success.
- 201 Created : Resources created.
- 204 No Content : Success but no content to return.
- 400 Bad Request : Invalid client input.
- 401 Unauthorized : Authentication required.
- 403 Forbidden : Client is authenticated but doesn't have permission.
- 404 Not Found : Resource not found.
- 500 Internal Server Error : Server-side error.
- 503 Service Unavailable : Server is down or unavailable.
Versioning API
- URI Versioning : /api/v1/customers
Use them directly in the URL path. - Custom Header Versioning : Accept-Version : v1
Use custom headers to specify the version.
Use query parameters
Use query parameters for filtering, sorting, searching and pagination.
Security
Use HTTPS to secure the data.