REST in practice: resources, verbs, and conventions
What it means to design a RESTful API, how to name routes, and when to use each HTTP method in real projects.
REST is not a framework: it is an architectural style. Model your domain as resources identified by URL and manipulate them with HTTP verbs in a predictable way.
Key principles
- Named resources: /orders, /users/12/profile.
- Meaningful verbs: GET reads, POST creates, PATCH partially updates.
- Interchangeable representations: JSON, XML, etc.
- Stateless: the server does not store UI session between requests.
GET /api/v1/products
POST /api/v1/products
GET /api/v1/products/88
PATCH /api/v1/products/88
DELETE /api/v1/products/88
Version your APIs (/v1/), paginate large collections, and return coherent HTTP codes. Your future team — and integrators — will thank you.