Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
secondsky avatar

Api Pagination

  • 325 installs
  • 202 repo stars
  • Updated August 4, 2026
  • secondsky/claude-skills

api-pagination is a Claude Code skill that implements offset, cursor, and keyset pagination patterns for developers who need scalable list endpoints and efficient database queries on large datasets.

About

api-pagination is a MIT-licensed agent skill from secondsky/claude-skills that walks developers through three pagination strategies—offset/limit, cursor, and keyset—for REST APIs and collection queries. The SKILL.md compares when each approach fits, documents O(n) versus O(1) performance tradeoffs, and includes JavaScript route handlers plus SQL patterns for building paginated endpoints, infinite scroll feeds, and optimized database reads. Developers reach for api-pagination when list endpoints slow down, OFFSET scans get expensive, or real-time infinite-scroll UIs need stable cursor tokens instead of page numbers. The skill is procedural reference material an agent loads while scaffolding or refactoring backend list APIs, not a deployable library. It pairs naturally with ORM query tuning and frontend infinite-scroll wiring in separate tasks.

  • api-pagination

Api Pagination by the numbers

  • 325 all-time installs (skills.sh)
  • +13 installs in the week ending Aug 5, 2026 (Skillselion tracking)
  • Ranked #1,270 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/secondsky/claude-skills --skill api-pagination

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs325
repo stars202
Last updatedAugust 4, 2026
Repositorysecondsky/claude-skills

How do you paginate large API datasets efficiently?

Use api-pagination for development tasks

Who is it for?

Backend developers adding or refactoring list endpoints where OFFSET performance or infinite-scroll stability is a concern.

Skip if: Developers who only need client-side table paging in an existing UI library with built-in pagination and no custom API design.

When should I use this skill?

The developer asks to add pagination, infinite scroll, or optimize slow collection queries on a list API.

What you get

Paginated route handlers, cursor token logic, and keyset SQL query patterns ready to paste into backend code.

  • Paginated endpoint handlers
  • Cursor token query logic
  • Keyset SQL patterns

By the numbers

  • Documents 3 pagination strategies: offset/limit, cursor, and keyset
  • MIT-licensed skill in the secondsky/claude-skills repository

Files

SKILL.mdMarkdownGitHub ↗

API Pagination

Implement scalable pagination strategies for handling large datasets efficiently.

Pagination Strategies

StrategyBest ForPerformance
Offset/LimitSmall datasets, simple UIO(n)
CursorInfinite scroll, real-timeO(1)
KeysetLarge datasetsO(1)

Offset Pagination

app.get('/products', async (req, res) => {
  const page = parseInt(req.query.page) || 1;
  const limit = Math.min(parseInt(req.query.limit) || 20, 100);
  const offset = (page - 1) * limit;

  const [products, total] = await Promise.all([
    Product.find().skip(offset).limit(limit),
    Product.countDocuments()
  ]);

  res.json({
    data: products,
    pagination: {
      page,
      limit,
      total,
      totalPages: Math.ceil(total / limit)
    }
  });
});

Cursor Pagination

app.get('/posts', async (req, res) => {
  const limit = 20;
  const cursor = req.query.cursor;

  const query = cursor
    ? { _id: { $gt: Buffer.from(cursor, 'base64').toString() } }
    : {};

  const posts = await Post.find(query).limit(limit + 1);
  const hasMore = posts.length > limit;
  if (hasMore) posts.pop();

  res.json({
    data: posts,
    nextCursor: hasMore ? Buffer.from(posts[posts.length - 1]._id).toString('base64') : null
  });
});

Response Format

{
  "data": [...],
  "pagination": {
    "page": 2,
    "limit": 20,
    "total": 150,
    "totalPages": 8
  },
  "links": {
    "first": "/api/products?page=1",
    "prev": "/api/products?page=1",
    "next": "/api/products?page=3",
    "last": "/api/products?page=8"
  }
}

Best Practices

  • Set reasonable max limits (e.g., 100)
  • Use cursor pagination for large datasets
  • Index sorting fields
  • Avoid COUNT queries when possible
  • Never allow unlimited page sizes

Related skills

How it compares

Pick api-pagination when designing new list API contracts; use ORM-specific skills when pagination is already abstracted by your data layer.

FAQ

What pagination strategies does api-pagination cover?

api-pagination covers three strategies: offset/limit for simple UIs, cursor pagination for infinite scroll and real-time feeds, and keyset pagination for large datasets needing O(1) lookups. The SKILL.md includes route and SQL examples for each.

When should developers use cursor over offset pagination?

api-pagination recommends cursor pagination when building infinite scroll or real-time feeds where stable O(1) reads matter. Offset/limit suits smaller datasets and page-number UIs but degrades on large tables because scans grow with page depth.

Backend & APIsbackendintegrations

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.