design-api-pagination

Design keyset-based cursor pagination for REST and GraphQL list endpoints.

9|3|Updated Jun 13, 2026
One-click install
npx skills add https://github.com/Sir-chawakorn/sanook-cli --skill design-api-pagination
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: design-api-pagination
Source: https://github.com/Sir-chawakorn/sanook-cli/tree/main/skills/design-api-pagination
Command: npx skills add https://github.com/Sir-chawakorn/sanook-cli --skill design-api-pagination

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill solves the performance degradation and data inconsistency issues inherent in traditional OFFSET-based pagination, such as slow deep-page queries and duplicate or missing rows during concurrent writes.

Core Features & Use Cases

  • Keyset Pagination: Implements O(1) cursor-based navigation that remains fast regardless of page depth.
  • Stable Ordering: Ensures consistent results by using unique tie-break keys to prevent row shuffling.
  • GraphQL Relay Support: Provides a standardized approach for implementing Relay-compliant connections.
  • Use Case: Ideal for building infinite-scroll feeds, search result pages, or large-scale data tables that require stable, performant navigation under heavy concurrent traffic.

Quick Start

Use the design-api-pagination skill to refactor the current list endpoint from offset-based logic to a keyset-based cursor implementation.

Frequently Asked Questions about design-api-pagination

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does API pagination break or show duplicate rows during concurrent writes?

API pagination using traditional OFFSET logic breaks during concurrent writes because newly inserted rows shift the offset window, causing duplicate or missing records. Keyset-based cursor navigation solves this by anchoring pagination to stable unique tie-break keys rather than positional offsets.

How do I implement keyset pagination for high-performance REST and GraphQL APIs?

Implement keyset pagination by using opaque base64url-encoded cursors derived from unique tie-break keys, applying limit+1 probing for efficient has_more detection, and filtering rows greater than the cursor value to achieve O(1) query complexity for REST and GraphQL endpoints.

What is the best way to handle deep-page query performance degradation in SQL?

The best way to handle deep-page SQL query performance degradation is replacing OFFSET with keyset pagination, which maintains O(1) query complexity regardless of page depth by using indexed cursor columns instead of scanning and skipping offset rows.

How do I build GraphQL Relay-compliant cursor connections for infinite scroll feeds?

Build GraphQL Relay-compliant cursor connections by implementing opaque base64url-encoded cursors mapped to unique tie-break keys, using limit+1 probing to detect has_more, and returning standardized connection edges and page info for stable infinite scroll feeds.

When should I not use keyset cursor pagination for my API?

You should not use keyset cursor pagination when your API requires arbitrary page jumping or random access to specific page numbers, as keyset cursors only support sequential forward and backward navigation anchored to specific row values rather than computed offsets.