REST API Best Practices – REST Endpoint Design Examples
ref: freeCodeCamp
REST stands for Representational State Transfer
Any API (Application Programming Interface) that follows the REST design principle is said to be RESTful.
A REST API is a medium for two computers to communicate over HTTP (Hypertext Transfer Protocol), in the same way clients and servers communicate.
REST API Design Best Practices
- Use JSON as the Format for Sending and Receiving Data
- Use Nouns Instead of Verbs in Endpoints
- Name Collections with Plural Nouns
- Use Status Codes in Error Handling
- Use Nesting on Endpoints to Show Relationships
- Use Filtering, Sorting, and Pagination to Retrieve the Data Requested
- Use SSL for Security
- Be Clear with Versioning
- the commonest versioning systems is semantic versioning
- An example of semantic versioning is 1.0.0, 2.1.2, and 3.3.4.
- The first number represents the major version,
- the second number represents the minor version,
- and the third represents the patch version.
- Provide Accurate API Documentation