
Api Pagination
This covers the three main pagination approaches you'll actually need: offset/limit for simple cases, cursor-based for feeds and infinite scroll, and keyset for massive datasets where offset breaks down. The reference guides include working examples in Node.js and Python with SQLAlchemy, plus specific patterns for search results and response formatting. The best practices are solid reminders, like capping page sizes at 100 and never using offset pagination on billions of rows. It's a practical reference when you're building an API and need to pick the right strategy without overthinking it. The code examples are clean and include the pagination metadata structure you'd actually want to return.
- skills.sh installs
- 495
- GitHub stars
- 379
- last updated
- Aug 21, 2026
Install
$ npx -y skills add aj-geddes/useful-ai-prompts --skill api-pagination --agent claude-codeInstalls into .claude/skills of the current project.
Files
API Pagination
Table of Contents
Overview
Implement scalable pagination strategies for handling large datasets with efficient querying, navigation, and performance optimization.
When to Use
- Returning large collections of resources
- Implementing search results pagination
- Building infinite scroll interfaces
- Optimizing large dataset queries
- Managing memory in client applications
- Improving API response times
Quick Start
Minimal working example:
// Node.js offset/limit implementation
app.get('/api/users', async (req, res) => {
const page = parseInt(req.query.page) || 1;
const limit = Math.min(parseInt(req.query.limit) || 20, 100); // Max 100
const offset = (page - 1) * limit;
try {
const [users, total] = await Promise.all([
User.find()
.skip(offset)
.limit(limit)
.select('id email firstName lastName createdAt'),
User.countDocuments()
]);
const totalPages = Math.ceil(total / limit);
Sponsors
Details
- Repository
- github.com/aj-geddes/useful-ai-prompts
- Categories
- Backend & APIs, AI & Agent Building, Debugging
- First seen
- Jun 3, 2026
More from aj-geddes/useful-ai-prompts
All 258- Container Debugging494
- Nosql Database Design492
- User Persona Creation492
- Database Indexing Strategy491
- Api Response Optimization490
- Uptime Monitoring490
- Background Job Processing488
- Accessibility Compliance487
- Git Workflow Strategy487
- Web Performance Optimization487
- Zero Trust Architecture487
- Frontend State Management485
- Cross Platform Compatibility484
- Incident Response Plan484
- Dns Management483
- File Upload Handling483
- Xss Prevention482
- Dependency Management481
- Circuit Breaker Pattern480
- Batch Processing Jobs479
- Aws Cloudfront Cdn478
- Mutation Testing478
- Api Changelog Versioning477
- Csrf Protection477