Skip to main content
Create your own
Lesson illustration

Custom API Calls with HTTP Request Node

Hello! Welcome to the next lesson in your journey to master n8n.

In our last session, we saw how to connect to hundreds of services "the easy way" using n8n's pre-built integration nodes. This is perfect when you need to perform common actions on popular platforms.

However, as a developer, you know that the real world is full of custom APIs, niche services, and specific endpoints that aren't covered by off-the-shelf solutions. This lesson addresses that gap and empowers you to connect to virtually anything with a REST API. Our learning outcome is to make custom API calls using the HTTP Request node. This node is your universal multitool, analogous to using axios in Node.js, requests in Python, or cURL on the command line.

1. From Pre-built Nodes to Custom Requests

Before diving in, let's frame this in a familiar context. In Node.js, you might poll an API for data like this:

// Node.js example
const axios = require('axios');

async function pollApi() {
  const response = await axios.get('https://api.example.com/data');
  // ...process the data
}

The n8n equivalent uses a trigger (like a Schedule node) followed by an HTTP Request node configured to perform that GET request. The HTTP Request node is your direct interface to the web's underlying protocol.

You'll need it in two main scenarios:

  1. The service has no pre-built n8n node. This could be an internal company API or a less common third-party service.
  2. The pre-built node exists but lacks a specific function. An integration node might support creating and deleting records but not a specific "search by custom field" endpoint that the API offers.

The following video provides an excellent introduction to why the HTTP Request node is so essential.

n8n HTTP Request Node & Tool (Connect to APIs)

The video 'n8n HTTP Request Node & Tool' by Ryan & Matt Data Science clearly explains the scenarios where a pre-built integration is insufficient and a custom HTTP call becomes necessary.

Watch from the beginning to 04:22. Focus on the explanation of when to use the HTTP Request node (when a native node doesn't exist or is limited) and the importance of reading API documentation.

2. The Anatomy of the HTTP Request Node

The HTTP Request node's parameters map directly to the components of a standard HTTP request. Since you're familiar with web development, these concepts will be a straightforward translation into the n8n interface.

n8n HTTP Request Node Configuration
The main parameters of the HTTP Request node: Method, URL, Authentication, and options for sending Query Parameters, Headers, and a Body.

Let's break down the main configuration fields, which you can also find detailed in the official n8n documentation.

  • Method: The HTTP verb for the action you want to perform. The most common ones follow the CRUD (Create, Read, Update, Delete) pattern:
    • GET: Retrieve data from a server.
    • POST: Create a new resource on a server.
    • PUT / PATCH: Update an existing resource.
    • DELETE: Remove a resource.
  • URL: The specific API endpoint you want to communicate with. You'll find this in the service's API documentation.
  • Authentication: How you prove you have permission to make the request. We'll cover this in more detail in the next lesson, but it often involves sending a secret key or token.
  • Send Query Parameters: Appends key-value pairs to the URL (e.g., ?status=active&limit=10). Often used with GET requests to filter or paginate results.
  • Send Headers: Sends metadata with your request. This is commonly used for authentication (e.g., Authorization: Bearer <your_token>) and specifying content types (e.g., Content-Type: application/json).
  • Send Body: The data payload of your request, typically used with POST, PUT, and PATCH. For most modern APIs, this will be in JSON format.

The following video succinctly explains these different components and their purpose.

n8n HTTP Request Node & Tool (Connect to APIs)

This segment of 'n8n HTTP Request Node & Tool' details the core components of a request: the method, the endpoint (URL), and the different ways to send data (query parameters, headers, and body).

Watch from 09:45 to 18:10. This will give you a solid conceptual overview of the HTTP methods and where different pieces of information (like filters, auth tokens, and data payloads) typically go.

3. Hands-On: Making a GET Request

Let's put this into practice by fetching data from a public API. We'll use the JSONPlaceholder API, a free fake API for testing and prototyping. Our goal is to retrieve a single user's data.

Workflow Setup:

  1. Create a new workflow. The default "Manual" trigger is fine for testing.
  2. Add an HTTP Request node.

Configuration:

  1. Method: Leave it as GET, as we are retrieving data.
  2. URL: According to the JSONPlaceholder documentation, to get a single user, the endpoint is /users/{id}. Let's use https://jsonplaceholder.typicode.com/users/1.
  3. Authentication: This API is public, so we can leave this as None.
  4. Execute the node by clicking Execute Step.

You should see the JSON data for user ID 1 in the output panel on the right.

HTTP Request Node in n8n
This image demonstrates the exact setup for our test: a GET request to the JSONPlaceholder API, with the resulting JSON data shown in the output panel.

Developer Shortcut: Import from cURL

Most API documentation provides example requests as cURL commands. n8n has a brilliant feature that lets you import these directly.

  1. Go back to the HTTP Request node's parameters.
  2. Click Import cURL at the top.
  3. Paste in a command like curl 'https://jsonplaceholder.typicode.com/todos/1' and click Import.

The node's URL will automatically update. This is an incredibly efficient way to configure nodes when you're working from API docs.

4. Hands-On: Creating Data with a POST Request

Now, let's create a resource. POST requests typically send data in the request body.

Configuration:

  1. Add a new HTTP Request node.
  2. Method: Change to POST.
  3. URL: Let's use the endpoint for creating posts: https://jsonplaceholder.typicode.com/posts.
  4. Send Body: Toggle this on.
  5. Body Content Type: Ensure it's set to JSON.
  6. Specify Body: You have two options:
    • Using Fields Below: Add key-value pairs one by one. This is good for simple bodies.
    • Using JSON: Write or paste a full JSON object. As a developer, you'll likely prefer this for its flexibility, especially when building complex objects or using expressions.

Let's use the Using JSON option. Enter the following into the JSON text area:

{
  "title": "My n8n Post",
  "body": "This was created using the HTTP Request node!",
  "userId": 1
}
  1. Execute Step. In the output, you'll see the API's response, which usually includes the data you sent plus a new id assigned by the server.

The process for PUT/PATCH (updating) and DELETE is very similar. You'd change the method and adjust the URL to include the ID of the resource you're modifying or deleting.

Test your understanding!

You need to update an existing user (ID: 5) in a system. The API documentation says you must make a PATCH request to /api/users/{id} and provide only the fields you want to change in a JSON body. You want to update the user's email to "new.email@example.com".

How would you configure the key parameters of the HTTP Request node?

Show answer
  • Method: PATCH
  • URL: https://your-api.com/api/users/5 (or similar base URL)
  • Send Body: On
  • Body Content Type: JSON
  • Specify Body (Using JSON):
    {
      "email": "new.email@example.com"
    }
    

Conclusion

You've now learned how to use the most powerful and flexible connector in the n8n toolkit. The HTTP Request node bridges the gap between n8n's convenient pre-built integrations and the limitless world of web APIs.

Key Takeaways:

  • The HTTP Request node is used when a pre-built integration doesn't exist or is missing a specific function.
  • Its parameters (Method, URL, Body, Headers, Query Params) map directly to standard HTTP request components.
  • Reading API documentation is the crucial first step to configuring the node correctly.
  • GET requests typically retrieve data, often using Query Parameters for filtering.
  • POST, PUT, and PATCH requests send data to a server, usually in a JSON Body.
  • The Import cURL feature can dramatically speed up your development workflow.

In our examples, we either used a public API or briefly mentioned putting an API key in the URL or headers. This is functional but not secure or reusable. In our next lesson, we will focus on how to authenticate with APIs using API keys, Bearer tokens, and OAuth2, leveraging n8n's secure credential management system to build robust and professional workflows.

Can't find a good explanation? Sign up and we'll make it for you

Sign up