API integrations form the backbone of modern workflow automation. Whether you are syncing data between services, pulling metrics from monitoring tools, or pushing notifications to team channels, understanding how to work with APIs in N8N unlocks the platform’s full potential.
This tutorial walks through building a complete API workflow that fetches data, transforms it, and sends output to an external service.
Prerequisites
Before starting, ensure you have:
- An N8N instance running (cloud or self-hosted)
- Access to the HTTP Request node
- A basic understanding of HTTP and JSON
- Test credentials for an API you want to integrate
Understanding the HTTP Request Node
N8N’s HTTP Request node handles all outbound API communication. It supports GET, POST, PUT, DELETE, and other HTTP methods. The node can authenticate using API keys, Bearer tokens, Basic Auth, or OAuth2.
Key configuration fields:
- Method: The HTTP verb (GET for retrieval, POST for creation)
- URL: The endpoint you are calling
- Authentication: How you prove your identity to the API
- Headers: Additional metadata the API requires
- Body: Data sent with the request (for POST/PUT)
- Output: How you want the response formatted
Building a Weather Data Integration
For this tutorial, we will build a workflow that fetches weather data and sends alerts when conditions exceed thresholds. This demonstrates API consumption, data parsing, and conditional logic.
Step 1: Set Up the Trigger
Every workflow needs a trigger. For this example, we use a Schedule trigger to run the workflow hourly.
- Add a “Schedule Trigger” node
- Configure: Every hour at minute 0
- Name it “Hourly Weather Check”
Step 2: Add the API Request
- Add an HTTP Request node
- Set method to GET
- Enter the weather API URL (using OpenWeatherMap as example)
- Add query parameters: city name, units, API key
- Configure authentication if required
The URL format: https://api.openweathermap.org/data/2.5/weather?q=CITY&units=metric&appid=YOUR_KEY
Step 3: Parse the Response
APIs return JSON that N8N automatically parses. However, you often need to extract specific fields for downstream processing.
- Add a “Set” node after the HTTP Request
- Use expressions to extract:
{{ $json.main.temp }}for temperature{{ $json.weather[0].description }}for conditions{{ $json.name }}for city name
Name this node “Extract Weather Data”
Step 4: Add Conditional Logic
We only want to send alerts when temperature exceeds a threshold.
- Add an “IF” node
- Configure the condition: Temperature > 35
- Connect the “Extract Weather Data” node to the IF node
The IF node splits your workflow into two branches: “true” (send alert) and “false” (end workflow).
Step 5: Send the Alert
For the “true” branch, add notification logic. We will use a Slack node as an example.
- Add a Slack node
- Configure your Slack webhook or connection
- Set the channel to your alert channel
- Compose the message using data from previous nodes:
Weather Alert: {{ $json.city }} is {{ $json.temp }}°C ({{ $json.description }})
Step 6: Add Error Handling
Production workflows need error handling for when APIs fail or return unexpected data.
- Add an “Error Trigger” node at the workflow level
- Configure it to capture errors
- Send error notifications to your monitoring channel
This ensures you know when automations break without discovering it through missed alerts.
Testing Your Workflow
N8N provides test execution before activating. Click “Test Workflow” to run with real API calls (limited executions during testing).
Watch the execution log to verify:
- API returns expected data
- Parsing extracts correct fields
- Conditional logic evaluates properly
- Alert sends when conditions met
Production Considerations
Rate limiting: APIs impose request limits. Add a Wait node between requests if your workflow makes multiple calls.
Pagination: Large API responses come in pages. Use the “Split In Batches” node to handle paginated results.
Authentication refresh: OAuth2 tokens expire. Implement token refresh logic or use long-lived API keys when possible.
Monitoring: Set up N8N’s built-in monitoring or connect to external monitoring to track workflow health.
Key Takeaways
- HTTP Request node handles all API communication
- Extract specific fields using Set node expressions
- IF nodes enable conditional logic paths
- Error triggers provide production failure visibility
- Test thoroughly before activating
FAQ
Can N8N handle API authentication? Yes, supports API key, Bearer token, Basic Auth, OAuth2, and header-based authentication.
How do I debug API issues? Enable “Test step” on individual nodes to see exactly what data moves through each step.
Can I chain multiple API calls? Yes, connect multiple HTTP Request nodes sequentially or use parallel branch execution for independent calls.
What happens if an API call times out? Configure timeout in the HTTP Request node. The workflow continues based on your error handling configuration.
How do I handle API rate limits? Use the Wait node to add delays between requests, or implement exponential backoff logic for retry scenarios.