HTTP API calls

Hi,

Is there any way to slow down the API calls between requests? I guess newer version we upgraded to which is 0.93.0 is more demanding than prior version which is .76.

Any suggestions will be helpful.

0.93 is a bit old, if you use the latest release there is a handy wait node that might do what you want.

1 Like

I was able to grab wait node from here, but how do I incorporate wait node between function node and http request node?

It should just be a case of dragging it in and placing it like any other node.

@dsuresh, are you making multiple requests in a single execution and you want to slow them down? Or are do you have many executions and you’d like to wait longer between them?

you can also use the batch interval and batch size if that helps with throttling
image

2 Likes

Hi @sirdavidoff,

I am not sure how to answer the question. Function node is feeding HTTP request node. Does that mean multiple requests in a single execution? How do I slow down?

How to use batch size and batch interval?

image

image

so you say how many requests you want to send in each batch and the interval between batches.

I use this to throttle requests against APIs that have rate limiting,

Thank you so much for the clearly explaining

1 Like

no problem

Hi @jan @RedPacketSec @sirdavidoff

Reg HTTP Request, I have dependency that prior request executed successfully before firing off the next API call. How do I achieve that? currently all bring fired feeding thru function node, all trying to execute at the same time.

I would like running in a single threaded mode, execute one at a time.

If you want that only one executes at a time you can set “Batch Size” to “1”.

@Jan, I have set the batch size to 1, batch interval to 9000. There are 900 requests, it should take atleast 2 hours, but its finishing in 10 minutes. Is it because multiple batches are running simultaneously. I only want 1 thread, 1 request. As there are calculations involved, which could change based on prior request. Currently all are executing simultaneously.

I just tested with a basic workflow and webhook.site. Seems to work totally correctly. Does only one request at a time:

{
  "nodes": [
    {
      "parameters": {
        "functionCode": "const newItems = [];\n\nfor (let i=0;i<900;i++) {\n  newItems.push({json:{i}});\n}\n\nreturn newItems;"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "authentication": "headerAuth",
        "url": "https://webhook.site/921ddada-7fca-4795-a8c4-d1578cf7ac9d",
        "options": {
          "batchInterval": 9000,
          "batchSize": 1
        },
        "queryParametersUi": {
          "parameter": [
            {
              "name": "q",
              "value": "={{$json[\"i\"]}}"
            }
          ]
        }
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        650,
        300
      ],
      "credentials": {
        "httpHeaderAuth": "unsplash"
      }
    }
  ],
  "connections": {
    "Function": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

@Jan,

unsplash do not exist error

Was just a basic test workflow. Authentication is not required. So you can simply deactivate authentication on the HTTP Request node.

Hi @Jan,

I was able to use SplitInBatches to take care of the issue. Is there anyway to add a wait node in between? I tried to add a wait node, I think its disrupting inputs when I add wait node.

As mentioned above, do not think that should be needed as it should work by setting the above-mentioned parameters.

The Wait-node does not change the data unless it is in webhook-mode. So should be no problem.

Thanks again @Jan. Always appreciate your promptness and willingness to assist.