REST conventions
Docs15 min
REST conventions
REST is a set of naming habits that make APIs guessable:
| Action | Route | Verb |
|---|---|---|
| List | GET /books | read |
| Read one | GET /books/42 | read |
| Create | POST /books | create |
| Replace | PUT /books/42 | update |
| Tweak | PATCH /books/42 | update |
| Remove | DELETE /books/42 | delete |
Nouns in the path, verbs in the method, status codes tell the truth: 201 created, 400 your fault, 401 unauthenticated, 404 not there, 409 conflict. An API that follows the table is half-documented by existing.
Exercise
Design the routes for a favorites feature on this roadmap app. Write the method + path + status code for each of the five actions.