2026-06-07
Mastering the n8n HTTP Request Node: Connect Any API Without Waiting for a Node
The HTTP Request node is n8n's superpower — connect to any REST API, even ones without native n8n nodes. Complete guide: authentication methods, pagination, error handling, response parsing, and 5 real-world API integrations.
Mastering the n8n HTTP Request Node: Connect Any API Without Waiting for a Node
n8n has 400+ native integrations. But for every API without a native node — and there are thousands — the HTTP Request node is your universal connector. REST APIs, GraphQL endpoints, webhooks, internal microservices. If it speaks HTTP, n8n can talk to it.
The Anatomy of an HTTP Request
Every API call has four parts:
| Component | Example | n8n Field | |---|---|---| | Method | GET, POST, PUT, DELETE | Method dropdown | | URL | https://api.example.com/v1/users | URL field | | Headers | Authorization: Bearer xxx, Content-Type: application/json | Headers section | | Body | {"name": "Alice"} | Body section (POST/PUT) |
Authentication Methods — Copy-Paste Templates
API Key in Header
Most common. Add an Authorization or X-API-Key header:
``` Header Name: Authorization Header Value: Bearer {{ $env.MY_API_KEY }} ```
API Key in Query String
Some APIs expect the key as a URL parameter:
``` URL: https://api.example.com/v1/data?api_key={{ $env.MY_API_KEY }} ```
Basic Auth
n8n has native Basic Auth support under "Authentication" → "Generic Credential Type" → enter username and password. Or build the header manually:
```javascript
// In a Function node before the HTTP Request
const username = $env.API_USERNAME;
const password = $env.API_PASSWORD;
const encoded = Buffer.from(${username}:${password}).toString('base64');
return { json: { ...$json, authHeader: Basic ${encoded} } };
```
OAuth2
For APIs that support OAuth2, use n8n's OAuth2 credential type. Configure client ID, client secret, auth URL, and token URL. n8n handles token refresh automatically — you just reference the credential in your HTTP Request node.
Handling Pagination
Most list endpoints paginate. Don't write manual loops — use n8n's built-in pagination:
- In HTTP Request node, enable "Pagination"
- Set "Pagination Mode" to "Response Contains Next URL"
- Set "Next URL" to the field containing the next page URL (e.g.,
{{ $response.body.next }}) - n8n auto-fetches all pages
For cursor-based pagination:
``` Next URL: https://api.example.com/v1/data?cursor={{ $response.body.cursor }} ```
For offset pagination:
``` Next URL: https://api.example.com/v1/data?offset={{ $response.body.offset + $response.body.limit }} ```
Parsing the Response
HTTP responses arrive as JSON (most APIs) or XML. n8n automatically parses JSON. For XML:
```javascript // In a Function node after the HTTP Request const xml2js = require('xml2js'); const parser = new xml2js.Parser(); const result = await parser.parseStringPromise($json.body); return { json: result }; ```
5 Real-World API Integrations
1. SendGrid — Send Transactional Emails
``` Method: POST URL: https://api.sendgrid.com/v3/mail/send Headers: Authorization: Bearer {{ $env.SENDGRID_API_KEY }} Content-Type: application/json Body: { "personalizations": [{"to": [{"email": "{{ $json.customer_email }}"}]}], "from": {"email": "hello@youragency.com"}, "subject": "Your Receipt", "content": [{"type": "text/plain", "value": "Thank you for your purchase!"}] } ```
2. Notion API — Create a Database Row
``` Method: POST URL: https://api.notion.com/v1/pages Headers: Authorization: Bearer {{ $env.NOTION_API_KEY }} Content-Type: application/json Notion-Version: 2022-06-28 Body: { "parent": {"database_id": "{{ $env.NOTION_DB_ID }}"}, "properties": { "Name": {"title": [{"text": {"content": "{{ $json.lead_name }}"}}]}, "Email": {"email": "{{ $json.lead_email }}"} } } ```
3. CoinGecko — Crypto Price Check
``` Method: GET URL: https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd ```
Response: {"bitcoin": {"usd": 65432}}
Use in an IF node: {{ $json.bitcoin.usd > 70000 }} → send Telegram alert.
4. OpenAI API — AI Text Generation
``` Method: POST URL: https://api.openai.com/v1/chat/completions Headers: Authorization: Bearer {{ $env.OPENAI_API_KEY }} Content-Type: application/json Body: { "model": "gpt-4o", "messages": [ {"role": "system", "content": "Summarize this feedback in 1 sentence."}, {"role": "user", "content": "{{ $json.feedback_text }}"} ] } ```
For local AI (free), use Ollama instead:
``` Method: POST URL: http://localhost:11434/api/generate Body: {"model": "hermes3:8b", "prompt": "Summarize: {{ $json.feedback_text }}", "stream": false} ```
5. Cloudflare DNS — Update a Record
``` Method: PUT URL: https://api.cloudflare.com/client/v4/zones/{{ $env.CF_ZONE_ID }}/dns_records/{{ $json.record_id }} Headers: Authorization: Bearer {{ $env.CF_API_TOKEN }} Content-Type: application/json Body: {"type": "A", "name": "home", "content": "{{ $json.new_ip }}", "ttl": 120} ```
This is a full dynamic DNS updater in one HTTP Request node.
Error Handling for HTTP Requests
Always check the response status:
```javascript
// After the HTTP Request node
if ($json.statusCode >= 400) {
throw new Error(API returned ${$json.statusCode}: ${JSON.stringify($json.body)});
}
```
Configure retries in the node's "Options" tab:
- Retry on Fail: enabled
- Max Tries: 3
- Wait Between Tries: 5,000 ms
When to Use HTTP Request vs Wait for a Native Node
- Native node exists? Use it. Better error handling, easier credential management.
- No native node? HTTP Request. It takes 5 extra minutes and the result is identical.
- Rapidly evolving API? HTTP Request. Native nodes sometimes lag behind API changes.
The HTTP Request node is your bridge to every API on the internet. All FlowForge templates use it extensively for services without native n8n nodes — you can study the patterns in any template's workflow JSON.
Related n8n Templates
These pre-built n8n templates complement what you just read. Import and run in minutes.
Data
Web Scraper → Google Sheets Archive
Scrape any website on a schedule and automatically append the data to Google Sheets. Track competitor prices, job listings, or news headlines.
Utility
Weather API → SMS Severe Weather Alert
Monitor weather conditions for any location and automatically send SMS alerts when severe weather is forecast. Great for construction, events, or farming.
Related Articles
More in-depth guides and comparisons to level up your n8n skills.
Ready to automate?
Browse 25+ production-ready n8n templates. Import, configure, and run — all in under 10 minutes.
Browse Templates