Pagination
Efficient data retrieval patterns for large datasets. Let agents control how data flows.
Pagination Strategies
Cursor-Based Pagination
Most reliable for changing datasets. Uses opaque cursor for position tracking.
{
"name": "orders___list_orders",
"arguments": {
"limit": 50,
"cursor": "eyJpZCI6MTIzfQ==",
"direction": "forward"
}
}The gateway gathers the API's pagination fields under _meta, next to the counts it derives in _meta._derived (abridged here):
{
"_meta": {
"source": "upstream",
"next_cursor": "eyJpZCI6MTczfQ==",
"has_more": true
},
"items": [{ "id": 124, "status": "shipped" }]
}Offset-Based Pagination
Simple but less stable. Good for static datasets.
{
"name": "products___search_products",
"arguments": {
"page_number": 3,
"page_size": 20,
"sort": "created_at"
}
}The page metadata arrives under _meta (abridged):
{
"_meta": {
"source": "upstream",
"page_number": 3,
"page_size": 20,
"total_pages": 15,
"total_count": 287
},
"items": [{ "id": "prd_241", "name": "Trail Jacket" }]
}Keyset Pagination
Uses actual data values for positioning. Efficient for large datasets.
{
"name": "events___list_events",
"arguments": {
"limit": 100,
"after_id": "evt_8291",
"after_timestamp": "2025-08-25T10:00:00Z"
}
}Iteration Patterns
Progressive Loading
Load data incrementally as needed:
1. Load first page (10 items) 2. Process and check if more needed 3. Load next page if criteria met 4. Continue until done or limit reached
Parallel Pagination
Fetch multiple pages concurrently:
// After getting total pages Promise.all([ fetchPage(1), fetchPage(2), fetchPage(3) ])
Windowed Iteration
Process data in sliding windows:
Window 1: Items 0-99 Window 2: Items 50-149 (50% overlap) Window 3: Items 100-199 (50% overlap)
Advanced Features
Adaptive Page Size
Adjust page size based on performance:
if (latency > 500ms) {
page_size = Math.max(10, page_size / 2)
} else if (latency < 100ms) {
page_size = Math.min(200, page_size * 2)
}Best Practices
Use stable sort orders
Always include a unique field in sort to ensure consistent pagination
Implement page size limits
Protect your API from excessive page size requests
Provide total counts carefully
COUNT(*) can be expensive; consider estimates for large datasets
Efficient data retrieval at scale
MCPify handles pagination complexity so agents can focus on the data.