Ep 08: Talking to the World — HTTP Request Node (Auth, Polling, Concurrency)
HTTP Request Is n8n's Swiss Army Knife
When n8n doesn't have a dedicated node for a service, HTTP Request is your universal fallback. It can manually call any REST API.
graph LR
subgraph "HTTP Request Capabilities"
HR[HTTP Request Node]
HR --> M1[GET / POST / PUT / DELETE]
HR --> M2[Headers / Body / Query Params]
HR --> M3[OAuth2 / API Key / Bearer Token]
HR --> M4[Auto Pagination]
HR --> M5[Timeout & Retry]
HR --> M6[Response: JSON / XML / Binary]
end
style HR fill:#ff6d5b,stroke:#e55a4e,color:#fff1. Authentication Methods
API Key Auth
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// Method 1: API Key in Header (most common)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// In n8n Credentials:
// Name: "Authorization"
// Value: "Bearer sk-xxxxxxxxxxxxxxxx"
// Method 2: API Key in Query Parameters
// "appid": "={{ $credentials.openWeatherApiKey }}" // Secure reference
OAuth2 Flow
sequenceDiagram
participant N8N as 🤖 n8n
participant Auth as 🔐 OAuth Server
participant API as 🌐 API Server
N8N->>Auth: 1. Redirect to authorization page
Auth-->>N8N: 2. User grants access → Authorization Code
N8N->>Auth: 3. Exchange Code for Access + Refresh Token
Auth-->>N8N: 4. Return Tokens (usually 1hr expiry)
N8N->>API: 5. Call API with Access Token
API-->>N8N: 6. Return data
Note over N8N: On expiry: auto-refresh handled by n8n!
N8N->>Auth: 7. Use Refresh Token to get new Access Token2. Pagination
graph TB
Start[Request Page 1] --> Check{Has next page?}
Check -->|"Yes"| Next[Request next page]
Next --> Merge[Merge Items]
Merge --> Check
Check -->|"No"| Done[Output all Items]
style Check fill:#f59e0b,stroke:#d97706// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// Offset-based pagination
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
{
"queryParameters": {
"limit": 100,
"offset": "={{ $pageCount * 100 }}" // n8n auto-increments $pageCount
}
// Stop: {{ $response.body.length === 0 }}
}
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// Cursor-based pagination (modern APIs)
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
{
"queryParameters": {
"cursor": "={{ $response.body.next_cursor || '' }}"
}
// Stop: {{ !$response.body.next_cursor }}
}
3. Error Handling & Retry
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// Error handling configuration
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
{
"options": {
"response": {
"neverError": true // Don't crash on 4xx/5xx — let downstream If handle it
},
"timeout": 30000, // 30s timeout (default is infinite!)
"retry": {
"maxTries": 3, // Max 3 retries
"waitBetweenTries": 1000 // 1s between retries
}
}
}
graph TB
HTTP[HTTP Request] --> Check{Status Code}
Check -->|"200"| Success[✅ Process]
Check -->|"429"| Wait[⏳ Wait 60s] --> HTTP
Check -->|"500"| Retry{Retries < 3?}
Retry -->|"Yes"| HTTP
Retry -->|"No"| Alert[🚨 Send Alert]
style Check fill:#f59e0b,stroke:#d97706Next Episode
In Ep 09, we unlock n8n's most powerful escape hatch — the Code Node — writing JavaScript and Python directly inside workflows for any data transformation.