← REST API Development learning path
REST API Development · Module 7 of 10

Pagination, filtering and sorting

Return large lists efficiently.

📖 Key ideas

  1. Never return thousands of rows at once.
  2. Offset pagination: ?page=2&limit=20.
  3. Cursor pagination: ?after=abc123 (stable for changing data).
  4. Filter: ?status=active; sort: ?sort=-created_at.
  5. Return totals or next links in metadata.
💡 Real-life example: Pagination is reading a book page by page instead of photocopying the whole book at once.
Offset paginationSkip N rows then take M
Cursor paginationContinue after a marker
limitMax items per page
SortingOrdering results