Skip to content

Sorting

Use the sort query parameter.

Single field

GET /customers?sort=name

Multiple fields

GET /customers?sort=name,created_at

Descending

GET /customers?sort=-name
GET /customers?sort=-name,created_at
import httpx

response = httpx.get("http://localhost:8000/api/customers", params={"sort": "-name,created_at"})
print(response.json())

Relationship path sorting

GET /computers?sort=owner.name
GET /computers?sort=-owner.name,serial

Practical examples

  • Newest-first customers: GET /customers?sort=-id
  • Owner then serial: GET /computers?sort=owner.name,serial