Skip to main content

Paginated API Collection

Loop through paginated API responses and collect all results

Steps

#ActivityWhat it does
1AssignInitialize page counter
2CreateTableCreate an in-memory table to accumulate items across pages
3WhileLoop while more pages exist
4HttpRequestFetch current page
5ForEachLoopPush each item from the page into the table
6TableUpsertRowAppend the item to the accumulated table
7TableExportExport 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")