Pagination to loop all pages

Describe the problem/error/question

I’m new to N8N. I need to loop all pages from this API.
https://bling.com.br/Api/v2/produtos/page=1/json/

After to run HTTP, I split in items and run all others nodes. I made this manually to change every page because I don’t know how to do that.

What is the error message (if any)?

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi @cesar_dev, happy to help with this one. Can you confirm how exactly your API behaves? I see it accepts a page parameter to query a specific page, but does it provide any information on the total number of pages in the response? Or any information on whether a next page exists or not?

Hello MutedJam,
There is no information about the number of pages. I think when there is no number, it’s the end of pages.

Hi @cesar_dev, so if all you want to do is increment the number of pages until you hit an error you could make use of the $runIndex variable provided by n8n. Like so:

This might need some tweaking depending on how exactly your API works, but this basic template should help with that.

Hello,

Thanks for clarify. It works.
Best regards,

Glad to hear, thanks so much for confirming :slight_smile: