Missing Manual - Http Request - Pagination

This working example of using the HTTP Request node with Pagination enabled might help with the basic understanding of how the Pagination feature works. The documentation doesn’t really describe how the feature behaves, so it might be natural to try guessing about what’s happening, and set up loops or other unnecessary things.

  • It helps some to first understand how n8n handles multiple items and passes them from one node to the next in the workflow.
  • Next it is important to understand that the Pagination feature is a client-side function, that, in a single execution of the HTTP Request node, fetches all the pages and passes each page as an item to the next node. So, if the paginated web service has 10 pages of data, 10 items will be emitted.
  • Finally the Pagination Complete When setup may need to detect the last page using something other than an empty response.

Copy the following into a workflow, and run it to see how it is working. The single execution of the HTTP Request node calls a public test/dummy paginated API (multiple times) and passes the output (pages) to a Split Out node. The dummy API returns 2 pages of data, and then a final page that has no data (only a message), so, 3 items total. The 2 pages have 6 items each in the data field of the response, so Split Out forwards 6, then 6, then 0 items (total of 12 single data items). The Pagination Complete When has an expression that detects when the data element in the response is empty, not the response (wrapper json) itself.

The particular paginated API you may be calling could work differently so this may need to be adjusted to match that service’s behavior. This is only meant to provide a working starting point to demonstrate how it is supposed to behave, and take some of the guesswork out of it.

3 Likes

nice I like this good work