Building ApplicationsLesson 44Free preview
REST API Design
This lesson is part of Node.js · All levels
Summary
REST API is an HTTP-based contract for the CRUD operation on the resource: GET to read, POST to create, PUT/PATCH to update, and DELETE to delete. Endpoints are designed based on noun resources, not action, to be consistent and easy to understand. Good responses also always use the correct status code.
Key points
- Endpoints are formed from resources, for example GET /users and GET /users/:id
- Use the status codes 200, 201, 204, 400, 401, 404, and 500 properly.
- HTTP method specifies the action: GET, POST, PUT/PATCH, DELETE
- API version (/v1) maintains the old client compatibility
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.