Online shop: catalogue, cart and orders
A small online shop. Customers browse products, keep a cart, and place orders. The server gives every cart item its own id when the item is added. A cancelled order stays on record with the status cancelled. The server finishes each request before it answers, and a successful delete returns no body.
For each request, choose the method and the path. Where there is a status slot, choose what the server returns when the request succeeds.
1.Show the product catalogue, page by page.
2.Show the page of product 31.
3.Add 2 of product 31 to the customer's cart.
4.Change the quantity of an item already in the cart, sending only the new quantity.
5.Remove an item from the cart.
6.Place the order from the cart.
7.Show order 42 with its current status.
8.Cancel order 42 before it ships, sending only the new status.
- GET /products → 200. Reading the collection; paging goes in the query string (?limit=…&cursor=…).
- GET /products/{id}: one item of the collection.
- POST /carts/{id}/items → 201 Created. The server assigns the new item's id, so the client POSTs to the collection; Location points to the new item.
- PATCH /carts/{id}/items/{item_id}: a partial update of one existing item.
- DELETE /carts/{id}/items/{item_id} → 204 No Content: success with no body.
- POST /orders → 201 Created, with Location: /orders/{id}.
- GET /orders/{id}.
- PATCH /orders/{id} with {"status": "cancelled"}. DELETE would remove the order, but the statement says cancelled orders stay on record.
Methods
Paths
Status codes
Tap a slot, then a part. Or drag a part into a slot. Each part can be used many times.