Skip to content
Prompt Words
History

Offset pagination

Also called: page-based pagination, limit and offset, numbered pages.

Each page skips a number of rows and takes the next few, so page 3 with 20 per page means skip 40, take 20. You can jump to any page and show a total, but new or deleted rows shift everything, and big skips get slow.

Each page skips a number of rows (page 2 = skip 3, take 3), so you can jump to any page. But when a new order arrives, every row moves down one, and the next page repeats one you already saw.

Page 1

Say it in a prompt

Paginate GET /api/orders with page and per_page (default 25, max 100) using LIMIT and OFFSET, ordered by created_at DESC and then id DESC. Return total and total_pages so the table can show numbered pages 1 to N with Previous and Next buttons.

Seen on

  • WordPress REST API: Collections take page, per_page and offset parameters and send X-WP-Total and X-WP-TotalPages headers with the totals.
  • GitHub REST API: Many list endpoints use page and per_page, with a link header pointing to the next, previous, first and last pages.

You might describe it as

  • numbered pages at the bottom of the table
  • jump straight to page 5 of the results
  • the same item shows up again on the next page

Not to be confused with

  • Cursor pagination

    Offset pagination counts rows to skip, so you can jump to any page; cursor pagination continues from the last item, can't jump, but never repeats.