A page boundary moves when the collection moves#
Returning an unbounded collection wastes memory, bandwidth, and query work. Splitting it into pages looks simple until new rows arrive or old rows disappear between requests.
Offset pagination#
GET /posts?limit=20&offset=40Offsets are easy to understand and support explicit page navigation. Large offsets may require the data store to skip substantial work, and concurrent inserts or deletes can shift items so a client sees duplicates or misses entries.
Cursor pagination#
GET /posts?limit=20&after=eyJjcmVhdGVkQXQiOi...A cursor represents a position in a stable ordering, commonly based on an ordered field plus a unique tiebreaker. The server returns the next opaque cursor; clients should not construct or depend on its encoding.
| Requirement | Offset | Cursor |
|---|---|---|
| Small administrative table | Simple and page-friendly | Often unnecessary |
| Large changing feed | Can shift or become expensive | Usually more stable |
| Jump to page 17 | Natural | Not naturally supported |
| Stable ordering | Still required for deterministic results | Required to define the cursor position |
Related practice problems
Use the manifest-backed prompts below to apply this lesson in a complete design.
- REST API Guidelines: CollectionsMicrosoft