Tips > Data, APIs & Webhooks

Batch API Calls Instead of Looping One-by-One

When processing multiple items, use the HTTP Request node's **batching** capability instead of calling the API in a loop for each item.

TipIntermediate2 min read

When processing multiple items, use the HTTP Request node's batching capability instead of calling the API in a loop for each item. Many APIs support batch endpoints, and even for APIs that do not, n8n's built-in batching processes items in configurable chunks with built-in delays to respect rate limits.

Real-world example: You need to geocode 500 customer addresses. Calling the geocoding API one-by-one takes 8 minutes and risks rate limits. Batching with controlled concurrency finishes in under 2 minutes.

// HTTP Request node configuration with batching
{
  "method": "POST",
  "url": "https://api.geocoding-service.com/v1/batch",
  "sendBody": true,
  "bodyParameters": {
    "jsonBody": "={{ { \"addresses\": $items.map(item => item.json.address) } }}"
  },
  "options": {
    "batching": {
      "batch": {
        "batchSize": 50,
        "batchInterval": 1000
      }
    }
  }
}
```text
For APIs without a batch endpoint, configure the HTTP Request node to process items in batches:

```yaml
HTTP Request node settings:
  URL: https://api.geocoding-service.com/v1/geocode
  Method: POST
  Body: ={{ { "address": $json.address } }}

  Options:
    Batching:
      Batch Size: 10          # Process 10 items at a time

      Batch Interval: 1000    # Wait 1 second between batches

    Retry On Fail: true
    Max Retries: 3
    Wait Between Retries: 2000
```text
If the API has a native batch endpoint, use a Code node to chunk items first:

```javascript
// Code node: "Prepare Batches"
const items = $input.all();
const batchSize = 50;
const batches = [];

for (let i = 0; i < items.length; i += batchSize) {
  const chunk = items.slice(i, i + batchSize);
  batches.push({
    json: {
      addresses: chunk.map(item => ({
        id: item.json.id,
        address: item.json.address
      })),
      batchIndex: Math.floor(i / batchSize)
    }
  });
}

return batches;
```text
Batching reduces total execution time, avoids rate limit errors, and often qualifies for bulk pricing discounts on APIs that offer them.

**Related:** [Use Structured Output (JSON Mode) for Parseable Responses](../ai-and-llm-integration/01-use-structured-output-json-mode-for-parseable-responses.md) | [Configure Payload Size and Binary Data Mode for Large Files](../performance-and-large-files/01-configure-payload-size-and-binary-data-mode-for-large-files.md)

Want this running in your stack?

I build production n8n and Cloudflare automation for teams — the same engineering behind HarperFlow. Fixed-price, escrow-protected, US-based.