HTTP Request Pagination

Hi all,

I have an custom endpoint that contains page parameter in body.

Example of body parameter:

page number will be dynamic.

Structure of node output:

["json": {"data":[Object], totalCount:Number}]

So, I know the totalCount and total objects returned per page. Total page number is

Math.ceil(totalCount / 250);

How can I design a loop to cover all pages? Thank you for your help.

n8n Setup

  • **n8n version:1.0
  • **Database: SQLite
  • **Running n8n with the execution process own
  • **Running n8n via Desktop app on MacOS

Hi @samaritan, welcome to the community :tada:

There are a couple of example workflows implementing pagination here on the forum. This thread would have an example checking if there is a next property present on the response but you should be able to adjust this to implement your own check. You can dynamically set a page number as needed using n8n’s expressions (which allow you to reference existing data as well as run JS on the fly).

Let me know if you run into any trouble with this!

1 Like

Hi @MutedJam,

Thank you for your help :pray: I can achieve a successful solution with your suggestion.

I’m attaching a link of a smooth example workflow of merging data with pagination for future readers.

1 Like