Products
A product is an item sold by the grocery. The API lets you list, read, create, update and delete it.
What you can do
| Action | Request | Who uses it today |
|---|---|---|
| List all products | GET /api/products/ | the web's / page |
| Read one product | GET /api/products/{id}/ | nobody (available) |
| Create a product | POST /api/products/ | the web's add form |
| Replace a product | PUT /api/products/{id}/ | nobody (available) |
| Update part of it | PATCH /api/products/{id}/ | nobody (available) |
| Delete a product | DELETE /api/products/{id}/ | the web's Delete button |
The details of each endpoint are in the Reference.
Business rules
- The name is required and at most 120 characters.
- The price is in euros, with two exact decimals. It cannot be negative. A price of
0is accepted (free product). - The stock is a non-negative integer. If not sent, it is
0. - The description is free and may stay empty.
- The id and dates are managed by the API. Those sent by the client are ignored.
- The list is always sorted by id, so by creation order.
Data that breaks these rules is refused with a 400: see Errors and validation.
What does not exist yet
| Missing | Consequence |
|---|---|
| Authentication | Anyone can create or delete a product through the public API |
| Pagination | The whole table is returned on every GET |
| Search, filters | Everything must be fetched and filtered client-side |
These items are tracked in the Limits; they will be addressed in the web part (702).
The full code is explained in The products API.