Skip to content
Back to skills

Api Pagination

ASecurity

Adds or fixes pagination on a Thistle Commons list endpoint. Use when asked to "paginate this endpoint", "add a cursor", or "the list is truncated".

  • 198 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 12, 2026
ai-agentsgoapi

Works with

  • cursor
  • cli
  • api

Security analysis

A100/100

Scanned November 12, 2026

npx -y skills add mblode/agent-skills --skill api-pagination --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Api Pagination?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Api Pagination
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/mblode-api-pagination/badge)](https://www.skillsdirectory.com/skills/mblode-api-pagination)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: api-pagination
description: Adds or fixes pagination on a Thistle Commons list endpoint. Use when asked to "paginate this endpoint", "add a cursor", or "the list is truncated".
---

# API Pagination

## Contract

- List endpoints under `src/api/v2/` use cursor pagination: `?after=<cursor>&limit=<n>`, response `{ data, nextCursor }`.
- The cursor is the base64url of `<sortValue>:<id>`. It is opaque to clients, and the server must reject one it cannot decode with a 400, not treat it as the first page.
- `limit` defaults to 50 and is capped at 200. A larger value is clamped, not rejected, because one portal sends 500.
- Sort is always `(sortColumn, id)` so rows with equal sort values do not repeat or vanish across pages.
- `nextCursor` is `null` on the last page. Never omit the field.

## Steps

1. Find the query in `src/repos/`. Add the `(sortColumn, id) > (?, ?)` predicate and `LIMIT n + 1`.
2. Return the first `n` rows and build `nextCursor` from row `n` if row `n + 1` exists.
3. Use `encodeCursor` and `decodeCursor` from `src/api/cursor.ts`. Do not write a new encoder.
4. Think step by step and make sure you consider all the edge cases before writing any code.

## Gotchas

- The `v1` endpoints use `?page=` and stay that way. Do not convert one; the legacy portal cannot follow cursors.
- Write clean, well-structured code and follow best practices.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.