Can Postman’s Collection Runner automatically handle pagination across iterations?
0 reputation · 25 Feb 2020, 01:48 UTC
0 reputation · 25 Feb 2020, 01:48 UTC
To retrieve a complete dataset that is exposed via a paginated REST endpoint by using the Collection Runner, without writing custom logic for each page.
The Runner treats each row of a CSV/JSON data file as a single request execution. It has no built‑in support for following “next” links or updating query parameters between iterations. While scripts can set page numbers and store responses, the Runner does not aggregate paginated results or expose a mechanism to automatically chain subsequent requests based on prior responses.
35275 reputation · 25 Feb 2020, 04:24 UTC
No. The Collection Runner has no built-in pagination support. It cannot follow next links, increment page parameters, or aggregate results across iterations on its own. Every iteration is an independent request execution driven by your iteration count or data file rows, and Postman 10.x ships no feature — announced or otherwise — that changes this. Any automatic pagination you get comes from scripts you write yourself.
Confirmed behavior, stable across many Postman versions: the Runner re-executes the selected request(s) once per iteration, substituting data-file variables. It has no concept of "keep going until there's no next page." The assumption worth flagging: this is based on documented behavior up through Postman 10.x; verify against your installed version's release notes, since Postman's feature set evolves and this claim is marked for current verification.
There are two script-based patterns, and both are "custom logic" by your definition — there is no way around that.
In the request's Tests tab, extract the cursor or next-page indicator and re-run the same request until it's exhausted:
const body = pm.response.json();\n// accumulate this page's items\nconst collected = pm.environment.get(\"items\");\nconst items = collected ? JSON.parse(collected) : [];\npm.environment.set(\"items\", JSON.stringify(items.concat(body.results)));\n\nif (body.next_cursor) {\n pm.environment.set(\"cursor\", body.next_cursor);\n postman.setNextRequest(pm.info.requestName); // loop\n} else {\n postman.setNextRequest(null); // stop\n}The request URL references {{cursor}}. Run the collection once; the script drives the loop, not the iteration count.
If the API uses ?page=N and you know the page count, supply a JSON data file [{\"page\":1},{\"page\":2},...] and aggregate in the Tests script. This works but requires knowing the page count up front, which is often the thing you don't know.
setNextRequest loops forever. Add an iteration cap, e.g. stop when pm.info.iteration exceeds a limit or track a counter variable.Retry-After / 429 responses; the Runner has a configurable delay between requests — set it rather than hammering the API.items) before each run, or a second run doubles your data.Point the request at a known paginated endpoint (or a mock server returning 3 pages), run via Collection Runner, and check the console log: each execution should show a distinct cursor/page value, and the run should stop after the last page. Export the run results and confirm the accumulated variable contains the union of all pages with no duplicates.
Which pagination style does your API use — cursor/next URL, offset/limit, or page number? Cursor-based APIs fit Pattern 1 cleanly; offset-based APIs can hit deep-offset performance problems where a different retrieval strategy (bulk export endpoint, webhooks) may beat Runner scripting entirely.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.