Connect n8n to Any API: Understanding HTTP Requests
This guide shows you how to use the HTTP Request node to connect to any API. By the end, you'll understand when to use different HTTP methods and how to send data to APIs.
The Secret Behind Every Node
Here's something most people don't realize: every pre-built node in n8n (Google Sheets, Slack, Send Email) is just an HTTP request behind the scenes. These platforms wrap common API calls in a friendly UI because they know most users will need them.
But there are millions of tools out there, and not all of them have native nodes. That's where the HTTP Request node becomes essential. It lets you connect to any service that offers an API.
What You'll Need
- An n8n instance (cloud or self-hosted)
- A URL to an API endpoint you want to call
Understanding HTTP Requests
When you visit a website or use an app, your device sends HTTP requests to servers. APIs work the same way. An HTTP request consists of these building blocks:
- URL (Endpoint) - Where to send the request. Each endpoint does a specific thing.
- Method - What action to take (GET, POST, PUT, PATCH, or DELETE)
- Headers - Extra information about your request, usually used for authentication where you pass your API key
- Query Parameters - Optional filters or settings added to the URL
- Request Body - Data to send along with the request (for POST, PUT, PATCH)
Each API has its own way of structuring these inputs. That's why every service has API documentation to show you exactly how to plug things in.
How to Find What You Need in API Docs
When working with a new API, here's the process:
Step 1: Find the API documentation. If you don't have a link, just Google: [service name] API documentation. For example, "Stripe API documentation".
Step 2: Look for the information you need. In the docs, you'll find a list of different endpoints along with explanations and code examples. Look for:
- Endpoint - The URL for your specific use case
- Authentication - How to pass your API key (90% of APIs use similar auth flows)
- Example Requests - Code examples to quickly understand the format
Pro Tips:
- Use cURL Imports in n8n: Most API docs include code examples in cURL format. Copy the cURL command and import it directly into n8n. It auto-fills all the fields for you.
- Let AI Read the Docs for You: Copy the relevant part of the docs, paste it into ChatGPT or Claude, and describe what you're trying to do. It will generate the cURL request for you, ready to import into n8n.
HTTP Methods Explained
Different methods tell the API what you want to do. Think of them as verbs:
| Method | Action | Example |
|---|---|---|
| GET | Read data | Fetch a list of products |
| POST | Create new data | Add a new customer |
| PUT | Replace data entirely | Update all fields of a user profile |
| PATCH | Update part of data | Change just a user's email |
| DELETE | Remove data | Delete a record |
Step 1: Making a GET Request
GET requests retrieve data without changing anything. They're the most common type of request.
- Add an HTTP Request node to your workflow
- Set Method to
GET(this is the default) - Enter the URL - for example:
https://pokeapi.co/api/v2/pokemon/pikachu - Click Execute
The response contains the data from that API endpoint. You can try entering this URL in your browser and see what data you get back.
Step 2: Making a POST Request
POST requests send data to create something new.
- Add an HTTP Request node
- Set Method to
POST - Enter the URL
- Turn on Send Body
- Set Body Content Type to
JSON - Enter your data using Body Parameters (name/value pairs) or JSON (raw format)
- Click Execute
The API typically responds with the created resource, including an id field.
Step 3: Sending Query Parameters
Query parameters filter or modify your request. They appear after a ? in URLs.
In n8n, turn on Send Query Parameters and choose how to specify them:
- Using Fields Below: Enter name/value pairs. Click Add Parameter for more.
- Using JSON: Enter JSON to define your parameters.
For example, to filter posts by user: add a parameter with name userId and value 1.
Step 4: Sending Headers
Headers contain metadata about your request. The most common use is authentication.
Turn on Send Headers and choose how to specify them:
- Using Fields Below: Enter name/value pairs like
AuthorizationandBearer your-token-here - Using JSON: Enter JSON to define your headers
Most APIs require either an API key header or a Bearer token for authentication.
Other HTTP Methods
PUT replaces an entire resource. Use it when updating all fields of a record. The URL typically includes the resource ID: https://api.example.com/users/123
PATCH updates only specific fields. Use it for partial updates when you don't want to replace everything.
DELETE removes a resource. The URL includes the resource ID and usually doesn't need a body.
Handling Responses
After a request executes, you can access the response in subsequent nodes:
{{ $json.fieldName }}- Access a top-level field{{ $json.nested.field }}- Access nested data{{ $json.array[0] }}- Access array elements
Handling Errors
By default, the HTTP Request node stops the workflow if the API returns an error. To handle errors gracefully:
- Open the node Settings
- Enable Always Output Data
- Enable Continue On Fail
Then use an IF node to check the response and handle errors appropriately.
You're Ready to Build
You now understand the fundamentals of the HTTP Request node:
- GET retrieves data
- POST creates new data
- PUT replaces data completely
- PATCH updates data partially
- DELETE removes data
- Headers handle authentication
- Query parameters filter requests
Practice What You Learned
Try these challenges to reinforce the concepts from this guide: