Why Pagination Matters

If you've ever built an API endpoint that returns a list, you've probably faced the question: what happens when the list has 10,000 items? Returning them all at once is a recipe for slow responses, memory exhaustion, and angry mobile users. Pagination is the answer, but not all pagination is created equal. Let's look at the three most common patterns: offset, cursor, and keyset pagination.

Offset Pagination (The Classic)

This is the simplest approach. The client sends page and per_page (or limit and offset), and the server skips that many rows.

# Flask example