API Pagination Best Practices: Offset vs Cursor vs Keyset (2026)

Deep comparison of Offset-Limit, Cursor-based, and Keyset pagination patterns in REST APIs with OpenAPI parameter schemas.

Unbounded collection queries crash databases and consume high network bandwidth. Implementing proper pagination guarantees fast response latencies regardless of table size.

1. Pagination Method Comparison

Pagination TypeQuery SignatureSQL ComplexityData Drift PreventionUse Case
Offset-Limit?page=3&limit=20OFFSET 40 LIMIT 20 (O(N))Poor (Duplicate/missing items on inserts)Small static tables, basic admin panels
Cursor-Based?startingAfter=cursor_xyzWHERE id > cursor LIMIT 20 (O(1))Perfect (Immutability guarantee)Real-time feeds, public APIs, mobile apps
Keyset?lastCreatedAt=2026-09-26T12:00:00ZWHERE created_at < ts LIMIT 20 (O(1))HighTime-series logs, event streaming

REST API Pagination Technical Comparison

cursor-pagination-schema.yaml
components:
  schemas:
    PaginatedResponse:
      type: object
      required:
        - data
        - hasMore
      properties:
        data:
          type: array
          items:
            type: object
        hasMore:
          type: boolean
          example: true
        nextCursor:
          type: string
          example: cur_92847293

Analyze Pagination Metadata Schemas

Upload your API specification into APIForge to inspect list endpoints for proper pagination query parameters and response objects.

Check Pagination Score โ†’

Ready to score and validate your API?

Paste any OpenAPI specification URL or YAML file into APIForge for instant 0-100 quality scoring, schema linting, and zero-CORS proxy testing.

Try APIForge Workbench โ†’
Share:๐• Postin Share

Frequently Asked Questions

Why is offset-limit pagination dangerous for large SQL tables?
SQL engines executing OFFSET 1000000 LIMIT 20 must scan and throw away 1,000,000 index entries before returning 20 records, leading to high CPU usage and slow responses.

Related Resources