DEV Community

Pirate Prentice
Pirate Prentice

Posted on

n8n HTTP Request Node: How to Call Any API (Free Workflow JSON)

If you've ever wanted to connect n8n to an API that doesn't have a native node — a custom internal API, a niche SaaS tool, a government data endpoint — the HTTP Request node is your answer.

It lets you make any GET, POST, PUT, PATCH, or DELETE request to any HTTP endpoint. Authentication, custom headers, query params, JSON body — all configurable without writing code.

This is one of the most powerful nodes in n8n, and most people never use it to its full potential.

What the n8n HTTP Request Node Does

The HTTP Request node sends an HTTP request to any URL and returns the response. That's it. Which means:

  • You can hit any REST API in the world
  • You can call webhooks and receive structured JSON back
  • You can chain multiple API calls in a single workflow
  • You can authenticate with API keys, Bearer tokens, Basic Auth, OAuth2, or custom headers

If an API has documentation, you can connect it to n8n in under 10 minutes.

Setting Up Your First HTTP Request

Drop an HTTP Request node onto your canvas. The key fields:

Method — GET, POST, PUT, PATCH, DELETE. Choose based on what the API expects.

URL — The full endpoint URL. You can use n8n expressions here: {{ $json.apiEndpoint }}

Authentication — This is where most beginners get stuck. Options include:

  • None (for public APIs)
  • Generic Credential Type → API Key (header or query param)
  • Generic Credential Type → Bearer Token
  • Basic Auth
  • OAuth2 (for Google, Slack, etc.)

Headers — Key/value pairs sent with the request. Commonly used for:

  • Authorization: Bearer your-token
  • Content-Type: application/json
  • X-API-Key: your-key

Query Parameters — Appended to the URL as ?key=value. Useful for filtering, pagination, search terms.

Body — For POST/PUT/PATCH requests. Set "Body Content Type" to JSON and paste your payload (or build it dynamically with expressions).

Practical Example: Calling a Public API (No Auth)

Let's fetch the current Bitcoin price from CoinGecko's free API.

  1. Add an HTTP Request node
  2. Method: GET
  3. URL: https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd
  4. Run it

You'll get back:

{
  "bitcoin": {
    "usd": 67420
  }
}
Enter fullscreen mode Exit fullscreen mode

Then use a Set node to extract {{ $json.bitcoin.usd }} and pass it downstream — into a Slack message, a Google Sheet row, an email, whatever you need.

Practical Example: Calling an Authenticated API

Most real APIs require authentication. Here's how to call the OpenAI API directly (useful when the native node doesn't expose a specific endpoint):

  1. Add HTTP Request node
  2. Method: POST
  3. URL: https://api.openai.com/v1/chat/completions
  4. Authentication: Generic Credential Type → Header Auth
    • Name: Authorization
    • Value: Bearer {{ $credentials.apiKey }}
  5. Headers: Content-Type: application/json
  6. Body (JSON):
{
  "model": "gpt-4o-mini",
  "messages": [
    {"role": "user", "content": "{{ $json.userMessage }}"}
  ]
}
Enter fullscreen mode Exit fullscreen mode

The response comes back as structured JSON you can parse with a Set or Code node.

Common Authentication Patterns

API Key in header (most common):

  • Use "Generic Credential Type" → "Header Auth"
  • Header name: whatever the API docs say (X-API-Key, Authorization, api-key, etc.)

API Key in query string:

  • Some APIs want ?api_key=xxx in the URL
  • Use "Generic Credential Type" → "Query Auth"

Bearer token:

  • Header: Authorization: Bearer your-token
  • Same as Header Auth above

Basic Auth:

  • Username + password sent as Base64
  • n8n has a built-in "Basic Auth" credential type — just enter username and password

Handling the Response

n8n parses JSON responses automatically. If the API returns:

{"results": [{"id": 1, "name": "Acme Corp"}]}
Enter fullscreen mode Exit fullscreen mode

You access it as {{ $json.results[0].name }} in the next node.

Pagination — Many APIs return results in pages. Use a loop with the Split In Batches or Loop Over Items node, incrementing a page parameter each iteration until you hit an empty results array.

Error handling — Turn on "Continue On Fail" in the node settings and add an If node that checks {{ $json.error }} to branch between success and failure paths.

Free Workflow JSON: HTTP Request Starter Pack

Here's a workflow that demonstrates three common HTTP Request patterns — public API call, authenticated API call, and error handling — wired together:

{
  "name": "HTTP Request Starter Pack",
  "nodes": [
    {
      "parameters": {},
      "id": "a1b2c3d4-0001",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [240, 300]
    },
    {
      "parameters": {
        "url": "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd",
        "options": {}
      },
      "id": "a1b2c3d4-0002",
      "name": "Get BTC Price (Public API)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [460, 300]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "field-001",
              "name": "btcPriceUsd",
              "value": "={{ $json.bitcoin.usd }}",
              "type": "number"
            }
          ]
        },
        "options": {}
      },
      "id": "a1b2c3d4-0003",
      "name": "Extract Price",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [680, 300]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://httpbin.org/post",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "X-Custom-Header",
              "value": "n8n-demo"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "btcPrice",
              "value": "={{ $json.btcPriceUsd }}"
            },
            {
              "name": "timestamp",
              "value": "={{ new Date().toISOString() }}"
            }
          ]
        },
        "options": {}
      },
      "id": "a1b2c3d4-0004",
      "name": "POST with Headers (Demo)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [900, 300]
    }
  ],
  "connections": {
    "Manual Trigger": {
      "main": [[{"node": "Get BTC Price (Public API)", "type": "main", "index": 0}]]
    },
    "Get BTC Price (Public API)": {
      "main": [[{"node": "Extract Price", "type": "main", "index": 0}]]
    },
    "Extract Price": {
      "main": [[{"node": "POST with Headers (Demo)", "type": "main", "index": 0}]]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

To use this: Copy the JSON above → open n8n → press Ctrl+V on the canvas.

The workflow:

  1. Triggers manually
  2. Fetches BTC price from CoinGecko (no auth needed)
  3. Extracts the price into a clean field
  4. POSTs it to httpbin.org (a free echo server) with custom headers — so you can see exactly what gets sent

Swap out the POST destination for your real API endpoint and add your auth credentials.

Tips and Gotchas

"Could not find property X" — The API returned an array, not an object. Add .items or [0] to your expression: {{ $json[0].name }}

401 Unauthorized — Your auth header name or format is wrong. Check the API docs — some want Bearer token, some want just token, some want the key in a completely custom header name.

CORS errors — n8n runs server-side so CORS doesn't apply. This error means something else (usually the URL is wrong or the server is blocking).

SSL certificate errors — On self-hosted n8n, toggle "Ignore SSL Issues" in node options as a last resort for internal APIs with self-signed certs. Don't do this for production external APIs.

Rate limits — Add a Wait node between batched HTTP calls. Most APIs allow 1 req/sec on free tiers; check the X-RateLimit-Remaining header in the response.

Want More Pre-Built n8n Workflows?

The workflow above is a sample from the n8n Workflow Starter Pack — 10+ production-ready workflows (lead capture, Stripe receipts, Slack alerts, Google Sheets sync, and more) with setup instructions.

Each workflow is plug-and-play: copy the JSON, paste into n8n, add your credentials, done.

Drop a comment below with the API you're trying to connect — I'll show you exactly how to set it up with the HTTP Request node.

Top comments (1)

Collapse
 
pirateprentice profile image
Pirate Prentice

What API are you trying to connect to n8n? Drop it below and I'll walk through how to set it up with the HTTP Request node — auth patterns, response parsing, whatever you're stuck on.