sort key
The field a collection is ordered by, chosen by the client from a small documented list, such as sort=title or sort=-id for descending.
In more detail
The server maps each allowed name to a known expression and rejects anything else with 400, so clients can never send raw database syntax. A cursor must encode the position in whichever order was chosen.
Examples
sort=idsort=-idRelated terms
- stable ordering — An order of results that is the same every time the same request is made, which pagination depends on.
- tie breaker — A final unique field, usually the identifier, added to a sort order so items with equal values always come out in the same order.
- cursor pagination — Paging by remembering the position of the last item seen and asking for items after it, such as ?after=2&limit=2.
- SQL injection — An attack where untrusted input is joined into a database query so that part of it runs as SQL, letting an attacker read or change data.
Taught in
- Sorting Results — Modern API Architecture: REST, GraphQL & gRPC