Home Computer Science
REST API design
When you are working with REST, there are some principles that you should keep in mind, and these principles should provide guidance for your design choices when you are doing API design.
HTTP verbs design
These are the following verbs found in HTTP:
Why do we keep saying often? Well, there are some exceptions in regards of size limitations. For instance, for the get verb, we can't have a request bigger than 8192 bytes or 8 KB. If you need to send a bigger payload, we will need to use the post verb.
Design Your REST API
REST uses a uniform API. For example, consider the following piece of code:
GET /users/1 = List information about user id 1
PUT /users/1 = Insert user 1
POST /users/1 = Update user 1
DELETE /users/1 = Delete user 1
GET /users/ = Lists All users
If we change the resource from users to sales, the API would almost be the same. Retrieving data is done using get and update is done via POST, so it's a uniform API.