An automation can connect to an API successfully, receive a valid response, and still produce incomplete results. The reason is often pagination: the API returns a limited number of records in each response, while the workflow assumes that the first response contains everything.
This problem is easy to miss during testing. A small account may return only a few records, so the first request appears complete. Once the data grows, the same workflow quietly processes only the first page and leaves the remaining records untouched.
Understanding pagination is essential whenever an automated process needs to collect a complete list of users, orders, files, messages, events, or other records from an external service.
Why APIs Split Results Into Pages
Returning thousands of records in one response can consume unnecessary bandwidth, memory, and processing time. Many APIs therefore limit the number of results returned by a single request.
A response might contain 100 records even when the account has several thousand. The API then provides a way to request the next group. The exact mechanism depends on the service, but common approaches include page numbers, offsets, cursors, and next-page URLs.
The important point is that a successful HTTP response does not necessarily mean the complete dataset has been retrieved. The workflow must check whether more results are available.
Recognize the Main Pagination Patterns
Page-number pagination uses a page parameter. A request might ask for page 1, then page 2, then page 3. The API may also allow a page-size parameter that controls how many records are returned at a time.
Offset pagination uses a starting position and a limit. For example, the first request may start at offset 0 and return 50 records. The next request starts at offset 50, followed by offset 100.
Cursor pagination uses a token returned by the previous response. The workflow sends that token with the next request. This approach is common when an API needs a more stable way to move through changing datasets.
Next-URL pagination returns a link or URL that identifies the next page. The automation follows that URL rather than calculating the next page number itself.
These methods are not interchangeable. Always read the API’s documentation and follow the specific parameter names and stopping rules it defines.
Use the API Response to Decide What Happens Next
A reliable pagination workflow should treat each response as both data and instructions for the next request. It should extract the records, inspect the pagination information, and determine whether another request is required.
For a cursor-based API, that usually means saving the returned cursor and sending it with the next request. For a next-URL API, it means following the supplied link. For a page-number API, it means incrementing the page value until the documented end condition is reached.
Do not assume that the last page is always identified by a short response. Some APIs return an empty list, while others provide a boolean such as `has_more`, a null cursor, or a missing next link. Use the condition defined by the API rather than inventing a generic rule.
Configure Pagination in an Automation Tool
Many workflow platforms provide built-in pagination support for HTTP requests. In n8n, the HTTP Request node includes pagination options for APIs that use changing request parameters or a next URL in the response.
For a page-number API, the workflow can update a query parameter between requests. For a cursor API, the next request can use a cursor field returned by the previous response. For an API that supplies a next URL, the pagination configuration can follow that value.
n8n’s documentation explains these modes and notes that the HTTP Request node can combine results from multiple pages. Its HTTP Request documentation and pagination examples are useful starting points when configuring a workflow.
Set a Clear Stop Condition
Every pagination process needs a reliable way to stop. Without one, a workflow can repeat the same request indefinitely, especially if the next-page value is configured incorrectly.
Common stop conditions include:
- The API returns no next-page URL.
- The cursor field is empty or null.
- The response explicitly indicates that no more records are available.
- The next page contains no records, when the API defines that as the end condition.
Also set a maximum number of pages or requests as a safety limit. This is not a substitute for the API’s proper stopping condition, but it can prevent a configuration error from creating an uncontrolled loop.
Plan for Changing Data
Pagination becomes more complicated when records are being created, updated, or deleted while the workflow is running. With offset pagination, new records inserted near the beginning of a list can shift later results. The automation may then retrieve some records twice or miss others.
Cursor-based pagination can reduce some of these problems, but it does not automatically guarantee a perfect snapshot. The API’s consistency model still matters. If the service supports filters such as creation time, update time, or a stable sort order, use them according to the provider’s guidance.
For recurring imports, store a reliable checkpoint such as the last processed timestamp or cursor when the API supports it. The next run can then retrieve new or changed records without downloading the entire dataset every time.
Handle Errors Without Losing Progress
A long pagination run may fail partway through because of a network interruption, authentication expiry, or API limit. Decide whether the workflow should retry the failed request, restart the import, or resume from a saved checkpoint.
Retries should be controlled. If an API returns a temporary error, a short delay may be appropriate. If it returns an authentication error, repeating the same request without refreshing credentials will not solve the problem.
Keep track of the page or cursor being processed, the number of records received, and the time of the last successful request. These details make incomplete imports easier to diagnose.
Check the Results, Not Just the Workflow Status
A workflow marked as successful does not prove that every expected record was collected. Compare the number of retrieved records with the API’s reported total when that information is available. Check for duplicate IDs and confirm that the first and last records match the intended range.
For larger imports, log the number of pages processed and the number of records returned by each page. A sudden drop in page count or record volume can reveal a broken cursor, an unexpected filter, or a changed API response.
Pagination is a small implementation detail with a large effect on data quality. Once the workflow handles the API’s pagination pattern, stop condition, changing data, and failure cases explicitly, it becomes much less likely to mistake a partial result for a complete one.



















