
Api Pagination
Solid reference implementation covering the three main pagination patterns you'll actually need in production. Offset/limit for simple cases, cursor-based for infinite scroll and real-time feeds, and keyset for performant queries on large datasets. The comparison table is helpful for choosing between them, and the examples show practical details like encoding cursors in base64, capping page sizes at 100, and avoiding expensive count queries. If you've ever written the same pagination logic three times across different projects or shipped offset pagination that crawled to a halt at page 500, this gives you patterns worth copying.
- skills.sh installs
- 433
- GitHub stars
- 248
- last updated
- Aug 21, 2026
Install
$ npx -y skills add secondsky/claude-skills --skill api-pagination --agent claude-codeInstalls into .claude/skills of the current project.
Files
API Pagination
Implement scalable pagination strategies for handling large datasets efficiently.
Pagination Strategies
| Strategy | Best For | Performance |
|---|---|---|
| Offset/Limit | Small datasets, simple UI | O(n) |
| Cursor | Infinite scroll, real-time | O(1) |
| Keyset | Large datasets | O(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() } }
: {};
Sponsors
Details
- Repository
- github.com/secondsky/claude-skills
- Categories
- Backend & APIs, Databases
- First seen
- Jun 3, 2026
More from secondsky/claude-skills
All 146- Api Filtering Sorting432
- Defense In Depth Validation430
- Session Management427
- Ultracite426
- Nuxt Production425
- Api Gateway Configuration422
- Oauth Implementation422
- Nuxt Ui V4421
- Health Check Endpoints420
- Cloudflare D1416
- Api Changelog Versioning415
- Dependency Upgrade415
- Idempotency Handling415
- Nuxt Server415
- Turborepo414
- Mobile Offline Support412
- Recommendation System412
- Api Versioning Strategy410
- Claude Code Bash Patterns408
- Claude Hook Writer408
- Logging Best Practices408
- Cloudflare Manager407
- Plan Interview406
- Ml Pipeline Automation402