When pulling live data from REST APIs in Alteryx, you quickly hit a common bottleneck: pagination. You configure the Download tool, hit Run, and celebrate when clean JSON comes back, only to realize the API capped your response at 100 records out of 15,000. You do not know how many pages exist upfront, and you cannot request Page 2 until Page 1 tells you where it lives.
If you read my previous post on Alteryx macros, you already know how to package repeatable logic into a reusable tool. Standard and Batch Macros work well when you know all inputs ahead of time, such as looping through 50 regional Excel files. API pagination is different because each request depends on the previous run's output, making it the textbook use case for an Iterative Macro.
Anatomy of a Paginated API Response
Alongside the records array (data), modern APIs return a pagination object pointing to the next batch:
{
"data": [ /* 3 records */ ],
"pagination": {
"current_page": 1,
"has_more": true,
"next_page_url": "...?page=2"
}
}{
"data": [ /* final record */ ],
"pagination": {
"current_page": 4,
"has_more": false,
"next_page_url": null
}
}On Page 4, has_more switches to false and next_page_url becomes null, giving us our stop condition.
How the Iterative Loop Works
Iterative macros can feel counterintuitive because data flows backward from an output anchor to an input anchor:

Step-by-Step Build: The Pagination Engine
Step 1: Set Up the Macro Input and Download
- Open a new workflow in Alteryx Designer and set the workflow type in Workflow Configuration to Iterative Macro.
- Add a Macro Input tool with a Text Input field named
URLcontaining your Page 1 endpoint ([https://api.example.com/v1/orders?page=1](https://api.example.com/v1/orders?page=1)). - Connect a Throttle tool (
5records per second) followed by a Download tool to avoid HTTP429rate limits. - In the Download tool's Basic tab, select
URLas the Field and output toDownloadData, then attach a JSON Parse tool.
Step 2: Split the Stream
Use two Filter tools branching off JSON Parse to separate records from your loop trigger.
Branch A: The Data Stream
- Filter:
StartsWith([JSON_Name], "data.") - Reshape: Connect a RegEx tool to
JSON_Namein Parse mode usingdata\.(\d+)\.(.*)to createRow_IDandField_Name. - Tabularize: Connect a Cross Tab tool. Group by
Row_ID, set headers toField_Name, and aggregateJSON_ValueStringusing First. - Output: Connect a Macro Output tool named
Data.
Branch B: The Loop Trigger
- Filter:
[JSON_Name] = "pagination.next_page_url" AND !IsNull([JSON_ValueString]) - Clean Schema: Use a Select tool to keep only
JSON_ValueStringand rename it toURLto match your Macro Input. - Output: Connect a second Macro Output tool named
Loop.
Step 3: Wire the Interface Designer
- Open the Interface Designer (
Ctrl + Alt + D) and click the Properties gear icon. - Set Iteration Input to your
Macro Inputand Iteration Output to yourLoopoutput. - Under Output Mode, select Auto Configure by Name (Wait Until All Iterations Run) so optional fields on early pages do not cause schema errors later.
- Set Maximum Number of Iterations to
100to prevent infinite loops, then save asAPI_Paginator.yxmc.
Adapting to Other Pagination Styles
If your API uses offset or cursor parameters instead of a full URL, add a Formula tool before your Loop output:
- Offset / Limit:
"[https://api.example.com/v1/orders?limit=3&offset=](https://api.example.com/v1/orders?limit=3&offset=)" + ToString(([Engine.IterationNumber] + 1) * 3) - Cursor / Token:
"[https://api.example.com/v1/orders?cursor=](https://api.example.com/v1/orders?cursor=)" + [JSON_ValueString]
Production Guardrails
- Catch Silent Failures: If Page 3 hits a
401or500error,JSON Parsewill find nonext_page_urland stop early with partial data. Add a Filter checkingContains([DownloadHeaders], "200 OK")connected to an error Message tool. - Use a Batch Macro When Page Count Is Known: If an API gives you
total_pages: 500on Page 1, use a Generate Rows tool (1to500) feeding a Batch Macro instead.
Once saved, drop API_Paginator.yxmc into your main workflow, feed it a single Text Input containing your Page 1 URL, and let it run. Instead of manually stitching together partial exports or writing custom Python scripts, you now have a reusable drag-and-drop tool that pulls complete datasets automatically.

