Now that we know what the application requirements are, we can move on to designing its API.
An important principle when creating RESTful URLs is to avoid using verbs in the URLs. Instead of having URLs such as /notes/getAll
or /notes/deleteNote
, we need to leverage existing HTTP methods such as GET
or DELETE
.
The thing to remember here is that we need to use nouns for resources and operate on them using HTTP methods. Let's apply this theory in practice and see how our endpoints will look; refer to the following table:
URL |
HTTP Method |
Action |
---|---|---|
|
|
This is used to get the public details of a specific user |
|
|
This is used to create a new user |
|
|
This is used to partially update the authenticated user |
|
|
This is used to retrieve the list of public notes shared by a specific user |
|
| ... |