Pagination
Overview
Pagination is essential for efficiently retrieving large datasets from APIs. Pullbay offers two pagination models to give you complete flexibility: Standard pagination for granular control and Managed pagination for simplicity. This guide explains both approaches, when to use each, and best practices for production workloads.
Why Pagination Matters
Large datasets present three critical challenges:
Performance: Retrieving millions of records in a single request strains both client and server resources, causing timeouts and memory exhaustion.
Network Efficiency: Breaking data into smaller pages reduces bandwidth usage and allows incremental processing.
Credit Control: Pullbay charges per request. Pagination lets you fetch only what you need, controlling costs and avoiding wasted credits on unused data.
Without pagination, a single request for 100,000 items would consume massive credits and likely fail. Pagination lets you process data incrementally, caching and stopping when you have enough results.
Standard Pagination (You Control the Flow)
Standard pagination gives you complete control: you request pages one at a time using the cursor parameter, process each, and decide whether to continue. This model is ideal when you need only a subset of data or want to implement custom logic.
How It Works
Make an initial request to the endpoint without a cursor
Receive the first page of results plus a
cursortoken in thepaginationblockRequest the next page by passing
cursor=<token>Repeat until
hasNextPageisfalse
Standard Pagination Response Format
Every paginated response includes a pagination block. Fields that are not relevant to the current endpoint are returned as null.
When hasNextPage is false, no more pages exist — stop paginating.
Example: First Request (No Cursor)
Example: Second Request (With Cursor)
When the final page is returned, hasNextPage is false and cursor is null:
Page-Based Pagination
Some endpoints support page instead of cursor. Pass page=<number> (1-indexed) and the response will mirror it in pagination.page:
Response:
Complete Python Implementation
Tips for Large Datasets with Standard Pagination
Stream results — don't wait for all data before processing. Use generators (as shown above) to handle results incrementally:
Checkpoint and resume — for long-running jobs, save the last cursor. If interrupted, resume from it instead of restarting:
Parallel fetching — if you have multiple IDs, fetch them concurrently:
When to Use Standard Pagination
Fine-grained control: You want to process data as it arrives
Subset of data: You need only the first N results, not everything
Cost efficiency: You want to stop early and avoid fetching unneeded data
Real-time processing: You're streaming results to another system
Managed Pagination (Pullbay Controls the Flow)
Managed pagination simplifies everything: pass maxItems in a single request, and Pullbay fetches all the pages internally and returns them in one response. Perfect for automation tools and batch jobs.
How It Works
Make a single request with
maxItems=<limit>set to the total number of records you wantPullbay fetches data across as many internal pages as needed
Receive a single response containing all matching items up to
maxItemsNo cursor handling or loop logic needed on your end
maxItems and cursor are mutually exclusive — you cannot combine them. The maximum value of maxItems varies by endpoint (see the endpoint reference for each service).
Example: Managed Pagination with cURL
Response (all up to 500 items in one response):
hasNextPage will be false because the response already contains everything up to maxItems.
Complete Python Implementation
When to Use Managed Pagination
Automation tools: Using n8n, Make.com, Zapier, or similar platforms
Complete datasets: You need all matching records up to the endpoint's limit
Simplicity: You prefer one request over pagination loops
Batch jobs: Running scheduled exports or data synchronization
Important: Timeout Configuration
Managed pagination fetches all pages internally, which takes longer than a single page. Set your HTTP client timeout accordingly:
Standard pagination (one page): 30 seconds is sufficient
Managed pagination (many internal pages): 60–120 seconds recommended
Choosing the Right Pagination Model
Building a custom application
Standard
Fine-grained control over data flow
Using n8n, Make.com, Zapier
Managed
Platforms prefer single requests
Need first 100 results only
Standard
Avoid fetching unnecessary data
Exporting all data monthly
Managed
Simplicity; no pagination loop needed
Real-time data processing
Standard
Process results as they arrive
Reducing credit usage
Standard
Fetch only what you need, stop early
Large dataset (near endpoint max)
Standard
Managed may timeout for very large sets
Simplest possible implementation
Managed
Single API call vs. pagination loop
Scheduled batch job
Managed
Fire-and-forget simplicity
Performance Comparison
Time to first result
1–2 seconds
Longer (Pullbay fetches all internally)
Total time for all data
Gradual (per page)
All at once
Memory usage
Low (process incrementally)
Higher (full result in one response)
Code complexity
Higher (cursor loop)
Low (single request)
Partial fetching
Yes (stop when you have enough)
No (fetches up to maxItems)
Best for
Custom apps, cost optimization
Automation tools, exports
Failure recovery
Easy (resume from last cursor)
Retry entire request
Credit Costs
The credit cost is identical for both models when fetching the same number of items.
Credits are always charged as: base_cost + (items_returned × 1).
If you fetch 500 App Store reviews for one app:
Standard: multiple requests totalling 500 items → same total credits
Managed with
maxItems=500: one request, 500 items → same total credits
The difference is control, not cost:
Standard: You decide how many items to fetch and can stop early
Managed: Pullbay fetches up to
maxItems; you pay for everything returned
To minimize costs with Managed pagination, use query filters to reduce the dataset before requesting:
Caching Strategies
Combine pagination with caching to maximize efficiency and reduce credit usage.
Standard Pagination Caching
Cache results by cursor key to avoid re-fetching pages:
Managed Pagination Caching
Cache the entire result as a complete dataset:
Cache TTL Guidelines
Real-time metrics
Minutes
5 minutes
Daily reports
Hours
6 hours
Historical reviews
Days
24 hours
Static app metadata
Weeks
7 days
Frequently Asked Questions
Summary
Choose Standard pagination for:
Custom control over data flow
Fetching subsets (first N results)
Cost optimization (stop early)
Processing results incrementally
Choose Managed pagination for:
Automation tools (n8n, Make.com, Zapier)
Complete dataset exports up to the endpoint limit
Simplicity (one request)
Batch jobs with sufficient timeout
Both models charge the same per item retrieved. The difference is flexibility and control. Combine either with caching for maximum efficiency and cost savings.
Last updated