API Design · Junior · Question 24 of 75
Where should filtering and sorting options go in a REST request?
- 1In the request body of a GET
- ✓Correct answer: In query parameters, e.g.
GET /orders?status=paid&sort=-createdAt - 3In the URL path, e.g.
/orders/status/paid/sort/createdAt
Explanation
Query parameters keep the resource URL stable and are cacheable. GET bodies aren't reliably supported by clients and proxies.