There are several ways to call external APIs in n8n, depending on your needs and the specific API you're working with.
Primary Methods
1. HTTP Request Node (Most Common)
The HTTP Request node is the most flexible way to call any external API:
Configuration:
- Method: GET, POST, PUT, DELETE, etc.
- URL: The API endpoint
- Headers: Add authentication tokens, content-type, etc.
- Body: For POST/PUT requests (JSON, form data, etc.)
- Authentication: Built-in support for various auth methods
Example setup:
- Method:
POST
- URL:
https://api.example.com/users
- Headers:
Content-Type: application/json
- Authentication:
Bearer Token or API Key
- Body: JSON data from previous nodes
2. Pre-built Service Nodes
n8n offers hundreds of pre-built nodes for popular services:
- Slack, Discord, Telegram for messaging
- Google Sheets, Airtable for data storage
- Stripe, PayPal for payments
- GitHub, GitLab for code repositories
- Salesforce, HubSpot for CRM
These nodes handle authentication and API specifics automatically.
3. Webhook Nodes
For receiving data from external APIs:
- Webhook node: Creates an endpoint to receive HTTP requests
- Webhook Response node: Send responses back to the caller
Best Practices
Authentication:
- Store API keys as credentials in n8n's credential manager
- Use environment variables for sensitive data
- Implement proper error handling for auth failures
Error Handling:
- Use the "Continue on Fail" option when appropriate
- Add conditional logic to handle different response codes
- Implement retry mechanisms for unreliable APIs
Data Processing:
- Use Set nodes to transform data between API calls
- Leverage Code nodes for complex data manipulation
- Use Split in Batches for handling large datasets
Example Workflow Pattern
- Trigger (Schedule, Webhook, etc.)
- HTTP Request to fetch data from API A
- Set node to transform the data
- HTTP Request to send data to API B
- Error handling and logging nodes
The HTTP Request node covers most external API integration needs, while pre-built nodes offer convenience for popular services. Choose based on whether a dedicated node exists for your target service and how much customization you need.