How to create a loop that will run for 100 times

Describe the problem/error/question

I am finding it a bit hard to explain my requirements, but let me try.

I have a need to iterate from count 1 to 100 and I need to use the value at each iteration as parameters in a HTTP request.

What I am trying to achieve is that:
I need to call an API a 100 times (where in I have to pass a value at each HTTP request like for example when called for first time it will be 1 then 2, etc.) every 10 minutes to fetch data. The fetched data will always return a collection of 100 data items. Which are then processed and some of the data returned is stored in Supabase.

Between each API call I have to wait for 10 second.

I checked the docs but could not find any information how to build a simple loop that runs for a fix number of times. The only node type that I found for loop is Batch node. But it seems to run on a collection.

What I am thinking is to create two workflows -
1st with a loop that will run a fix number of times and
2nd with the actual logic to call the API and process the returned data. Here the 3nd workflow will have a variable that will contain the value of iteration and which will be used in the API.

I hope I have managed to explain my requirements properly to get some help in setting this up.

Thanks in advance.

Hey @YogiYang ,

Here’s a workflow you can import to n8n to do what you’re looking for:

3 Likes

Wow!!

This works like a charm.

I am still new but what I understood is that we are first creating an array of required values using Javascript and then in next stage processing each item by splitting the array.

Thank you.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.