📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials API Design Filtering and Sorting

Filtering and Sorting

4 min read Quiz at the end
Query params for filtering, sorting, field selection, and including related resources without N+1.

Filtering, Sorting and Search

# Filtering
GET /posts?status=published&author_id=42
GET /posts?created_after=2024-01-01
GET /posts?price_min=10&price_max=100

# LHS bracket notation
GET /posts?price[gt]=10&price[lt]=100

# Sorting
GET /posts?sort=created_at        # ascending
GET /posts?sort=-created_at       # descending
GET /posts?sort=-views,title      # multi-field

# Field selection
GET /posts?fields=id,title,created_at

# Include related resources
GET /posts?include=author,tags
Topic Quiz · 1 questions

Test your understanding before moving on

1. What HTTP method should be used to apply a partial update to a resource?
💡 PATCH applies a partial modification — only the specified fields are changed, unlike PUT which replaces.