Is the order of data between nodes guaranteed?

hello, I’m trying to call the API in batches

For example, I have an array of 10 keys to use as parameters.
json

[
    {
        "key": "1"
    },
    {
        "key": "2"
    },
    ...
    {
        "key": "10"
    }
]

Use the HTTP request node to run the batch in units of 5 as follows:

And the expected result of the API is:

{
    "success": boolean,
    "data": {
        "reqId": string
    }
}

What I want to do here is to combine the parameter (key) passed in when calling the API and the data of the result value and save it as tsv.
I made the following using the executeCommand node.

result file is saved as:

1	true	17a2ca2e-8bbc-49a8-8b9b-bdb7b20bd662
2	true	bd0ea76e-4769-4f1a-9845-aa73152ab458
3	true	20686b48-07c0-41a0-841e-a00563bc6aed
4	true	43854606-86eb-4c38-aa41-ae8e48cec001
5	true	51473bc5-17fa-4f4b-9be4-61bf59807280
6	true	c09901a4-337b-4655-918d-2909a802329f
7	true	ef4c5fb0-a99f-4b9d-9663-29a74cda6f41
8	true	1ddd4d88-f603-4279-97bd-0c5c824141f5
9	true	caca7c5c-d02a-469e-9ceb-e648a1c76fc1
10	true	0baf9a28-abda-4451-87ab-34336fe0ea93

When only 10 calls are tested, it seems that the order of key and reqId is guaranteed.
The question here is whether we can guarantee the data order of each node, even with tens of thousands of requests, as in the results of the 10 tests above.

If the order is not guaranteed, what is a good way to combine the response data of the HTTP request with the data of the previous node?

Thank you in advance.
lee

Hi @YongMoon_Lee, welcome to the community :tada:

n8n would not change the order of items as they are processed sequentially. So the first item before the HTTP request would correspond to the first item after the HTTP request (same for the second, third, etc. item).

Here’s a quick test workflow, you can set any number in the initial Function node if you’d like to double-check this yourself. It uses the /anything endpoint from httpbin.org, which is a great service for testing such scenarios (as it responds simply with the data it has received).

Example Workflow
1 Like

@MutedJam Thank you :slight_smile:

it really helped a lot

1 Like

Awesome, glad to hear that. Thanks a lot for confirming!

Hi,

If I use a switch node after the function node, will it still execute the data sequentially? I found that with the switch node, it is not executing the nodes sequentially. Please find the link to the question which I have raised - Switch node execution flow

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