For the complete documentation index, see llms.txt. This page is also available as Markdown.

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:

  1. Performance: Retrieving millions of records in a single request strains both client and server resources, causing timeouts and memory exhaustion.

  2. Network Efficiency: Breaking data into smaller pages reduces bandwidth usage and allows incremental processing.

  3. 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

  1. Make an initial request to the endpoint without a cursor

  2. Receive the first page of results plus a cursor token in the pagination block

  3. Request the next page by passing cursor=<token>

  4. Repeat until hasNextPage is false

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

  1. Make a single request with maxItems=<limit> set to the total number of records you want

  2. Pullbay fetches data across as many internal pages as needed

  3. Receive a single response containing all matching items up to maxItems

  4. No 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

Scenario
Best Choice
Reason

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

Metric
Standard Pagination
Managed Pagination

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

Data Type
Freshness
Recommended TTL

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

Are cursor strings safe to store?

Yes, but treat them as temporary tokens. Cursors are opaque (you cannot modify them), may expire after some time, and are tied to the specific query that generated them. You can safely store them in a database for resuming interrupted jobs.

Do cursors expire?

Yes. If you resume from an expired cursor, the API will return an error. Handle this by catching the error and restarting from the beginning:

What is the difference in credit cost between standard and managed pagination?

There is no difference for the same number of items fetched. Both charge base_cost + (items × 1). The practical difference is that with Standard you can stop early (and pay less), while Managed always fetches up to maxItems.

Can I use managed pagination in n8n?

Yes. Set maxItems as a query parameter in your HTTP Request node. n8n will execute the single request, receive all results in one response, and process them — no pagination loop needed in your workflow.

What happens if `maxItems` exceeds the endpoint's limit?

The API caps the result at the endpoint's maximum (e.g. 500 for App Store reviews). Requesting maxItems=9999 on that endpoint returns at most 500 items. Check the endpoint reference for each service's maximum.

Can I combine `cursor` and `maxItems`?

No. They are mutually exclusive. Providing both will result in a 400 VALIDATION_ERROR.

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