๐ŸŽ“Iris Courses
โ† AI Automation Mastery
Day 6 of 21

Connecting to Any API

The HTTP Request Node Is Your Superpower

n8n has 400+ built-in integrations, but the real power comes from the HTTP Request node โ€” it lets you talk to any API that exists. If there's a REST API, you can integrate it. This includes internal APIs for your own products, obscure SaaS tools with no native integration, government data APIs, financial data providers, and anything you build yourself. HTTP Request node basics: you specify the method (GET, POST, PUT, DELETE, PATCH), the URL, headers (where your API key goes), query parameters, and request body. For GET requests, you're fetching data. For POST/PUT, you're sending data to create or update records. Authentication is the first thing to get right. Most APIs use one of these patterns: API Key in a header ('Authorization: Bearer YOUR_KEY' or 'X-API-Key: YOUR_KEY'), Basic Auth (username:password encoded in base64), OAuth 2.0 (n8n has built-in OAuth support for many providers), or a query parameter ('?api_key=YOUR_KEY'). In n8n, store your API credentials in the Credentials section โ€” never hardcode them in the node. This lets you rotate credentials without editing every workflow that uses them. Practical example: the Airtable API isn't well-supported in older n8n versions, but the HTTP Request node works perfectly. You can create records, update them, query with filters, and delete them using Airtable's well-documented REST API. This approach works for literally any SaaS tool with an API.

Handling API Responses and Pagination

An API call returns a response. How you handle that response determines whether your automation is robust or fragile. First, always check the status code. 2xx means success. 4xx means your request was wrong (bad API key, malformed request body, insufficient permissions). 5xx means the server had a problem. n8n's HTTP Request node can be configured to continue or stop on error โ€” choose carefully based on your use case. Response parsing: most modern APIs return JSON. n8n automatically parses JSON responses and makes them available as structured data in subsequent nodes. But some APIs return XML, CSV, or even plain text โ€” you'll need to parse these yourself using the Code node. Pagination is the feature most automation tutorials skip, but it matters the moment you're fetching more than 100 records. APIs typically paginate responses to limit server load. Common patterns: offset-based ('page=2&per_page=100'), cursor-based (next_cursor in the response), and link-based (next URL in the Link response header). In n8n, handle pagination with a Loop node. Fetch the first page, extract the next page cursor or URL, check if there's a next page, loop back if yes, merge all pages when done. This sounds complex but takes about 10 minutes to set up once you've done it once. Rate limiting is the other common gotcha. Most APIs limit how many requests you can make per second or per minute. Add a Wait node between API calls if you're making many requests in a loop โ€” a 500ms wait is often enough to stay within limits.

โšก Today's Action

Pick any API you already use (your CRM, email tool, analytics platform, or a public API like GitHub or OpenWeatherMap) and build an HTTP Request node that fetches some data. Display the result in a Slack message or Google Sheet.

๐Ÿ’ก Pro Tip

Use the 'Always Output Data' option in the HTTP Request node's error handling settings, and pair it with an IF node to check response status codes. This gives you explicit control over the success/failure path rather than relying on n8n's default error behavior.