How-to: Paginate through an API
Most APIs return results in pages. Publicus has two built-in pager connectors that iterate through pages automatically:
- Pager / OffsetBased — for APIs that accept
offset+limit. - Pager / PageBased — for APIs that accept
page+size.
This guide shows how to set up each one.
How pagers work
Section titled “How pagers work”A Pager connector runs the sub-graph wired to its iteration handle
once per page. After each page it evaluates the endCondition
expression. When that condition is truthy, no further page is queued and
the pager’s output handle activates, so any post-pagination steps run.


Before each page runs, the pager works out the numbers that page will
use and freezes them into the page’s start data. The sub-graph reads
them through $page:
| Path | Description |
|---|---|
$page->index |
Zero-based page counter (the first page is 0). |
$page->startData["nextPage"] |
The page number for the page currently running. |
$page->startData["nextSize"] |
The page size for the page currently running. |
$page->startData["nextOffset"] |
The record offset for the page currently running (OffsetBased only). |
Inside a @json block the same values are reached as JSONPath strings:
"$.page.startData.nextPage" is the @json spelling of
$page->startData["nextPage"]. See
Connectors for the full $page
reference.
Using Pager / PageBased
Section titled “Using Pager / PageBased”Example: GitHub API style (?page=1&per_page=30)
Section titled “Example: GitHub API style (?page=1&per_page=30)”-
Drop a Pager / PageBased connector on the canvas.
-
Connect an upstream node’s
outputto the connector’sinput. -
Configure:
startPage: 1startSize: 30endCondition: $page->index == 100 || count($page->prevOutput->items) == 0That stops pagination when the
itemsarray in the response is empty, with a 100-page bound so a misbehaving API cannot page forever. -
Wire a Transformer to the connector’s
iterationhandle:@json{"page": "$.page.startData.nextPage","per_page": "$.page.startData.nextSize"}@endjson -
Connect the Transformer’s
outputto an OpenApi / Operation or Rest / Operation that calls the API with those parameters. -
Wire the API response downstream for processing (store, transform, and so on).
Using Pager / OffsetBased
Section titled “Using Pager / OffsetBased”Example: offset + limit (?offset=0&limit=50)
Section titled “Example: offset + limit (?offset=0&limit=50)”-
Drop a Pager / OffsetBased connector.
-
Configure:
startSize: 50startOffset: 0endCondition: $page->index == 100 || count($page->prevOutput->data) == 0 -
Build the request parameters in a Transformer wired to
iteration:@json{"offset": "$.page.startData.nextOffset","limit": "$.page.startData.nextSize"}@endjson
Writing the end condition
Section titled “Writing the end condition”endCondition is the only pager field that can read $page->prevOutput,
the output of the page that just finished. The next* fields are frozen
before their page runs, so they see only $page->index and the pager’s
own start configuration.
Two consequences follow:
- The idiomatic stop tests the previous response:
count($page->prevOutput) == 0, or whatever emptiness marker the API uses. - Cursor pagination is not supported. A pager cannot take a
next_cursorout of a response and feed it to the following request. ThenextPagePropertyandnextSizePropertyfields look like they do this, but nothing reads them. They are reserved, inert, and safe to leave empty.
Choose what the pager emits
Section titled “Choose what the pager emits”outputMode decides what leaves the pager’s output handle once every
page has run:
| Mode | Emits |
|---|---|
summary |
{"count": n}, the number of pages that ran. This is the default. |
combine |
Every page’s output, in page order, as one JSON array. |
Set combine when a node after the pager has to read the records
themselves. Keep summary when the iteration sub-graph already did the
work, because the combined aggregate is stored in the run’s record and
a long run makes that large.
The node wired to the output handle receives the result as $prev.
Any node further down reads the same result by the pager’s name, for
example $workflow->node('Fetch all orders').
Monitor page-by-page progress
Section titled “Monitor page-by-page progress”On the canvas, show a run with Show on the canvas in the Runs rail (see Watching runs on the canvas). The pager then says how its pages are going, under its own state: for example “12 done · 1 running · 2 failed”, with failed in red. The counts update while the run goes on. There is no total, because the pager finds out it is on the last page only when the end condition says so. A pager inside another pager counts the pages of every outer page together.


Every page is a separate activity in Runs. Open a run and expand the pager to see each page’s input (the request parameters) and output (the API response). This shows exactly where pagination stopped or which page produced an unexpected result.


- Set an
endConditionthat reflects your API’s actual empty state, and keep the page-index bound alongside it. - If the API has a rate limit, the per-page retry policy gives you natural throttling.
Related
Section titled “Related”- Connectors — full connector reference with the
$pagetable. - How-to: Parallel processing — combine paging with parallel element processing.
- OpenApi / Operation — typed API calls.