Paginated API Collection
Loop through paginated API responses and collect all results
Steps
| # | Activity | What it does |
|---|---|---|
| 1 | Assign | Initialize page counter |
| 2 | CreateTable | Create an in-memory table to accumulate items across pages |
| 3 | While | Loop while more pages exist |
| 4 | HttpRequest | Fetch current page |
| 5 | ForEachLoop | Push each item from the page into the table |
| 6 | TableUpsertRow | Append the item to the accumulated table |
| 7 | TableExport | Export the accumulated rows to Excel |
Workflow
page, hasMore = Assign({'page': 1, 'hasMore': True})
CreateTable("allResults", schema={"columns": [{"name": "id"}, {"name": "name"}]})
while hasMore:
pageData = HttpRequest("{{ 'https://api.example.com/items?page=' + page }}", "GET")
for item in pageData.items:
TableUpsertRow("allResults", {"id": "{{ item.id }}", "name": "{{ item.name }}"}, append=True)
page, hasMore = Assign({'page': '{{ page + 1 }}', 'hasMore': '{{ pageData.hasNext }}'})
TableExport("allResults", "./all_results.xlsx", format="xlsx", sheetName="Results")