Dec 02, 2025
Aris S. & Valentinas C.
13min Read
Integrating an application programming interface (API) with n8n can be complicated because every API provider has specific requirements for connecting their service. Nevertheless, n8n’s code-minimal workflow can allow you to create a highly efficient yet easy-to-maintain data pipeline that will benefit a wide range of automation scenarios.
Integrating an API into your n8n workflow consists of ten steps:
Note that creating an efficient workflow goes beyond these steps and involves properly maintaining its security and scalability. To improve your workflow maintainability, consider using the OneSimpleAPI node, which offers pre-configured API endpoints for basic tasks that you can manage directly in n8n, unlike other third-party APIs.
Read on to learn about n8n-API integration in detail, explore tips for securing your workflow, and dive into some common usage scenarios.
In this section, we’ll go into all the steps for integrating an API with your n8n instance.
Before creating a workflow and integrating an API, you’ll need to set up your n8n instance. In this tutorial, we’ll focus on the self-hosted version because it offers more control and is more affordable than the official plan.
Self-hosting n8n requires a virtual private server (VPS) hosting plan. You can use one from any provider as long as it offers sufficient hardware resources to ensure your workflow runs responsively and adequately.
Since we are creating a simple workflow, a server with 1 vCPU core and 1 GB of RAM is enough, but you’ll need more hardware resources if you plan to create multiple automation scenarios.
The steps to install n8n remain the same regardless of your VPS provider. However, we recommend Hostinger’s n8n hosting plan if you want a straightforward, command-free configuration process.

After purchasing Hostinger’s n8n hosting plan, our system will automatically choose the n8n template for your server. Then all you need to do to install n8n is complete the VPS onboarding process, which involves basic tasks like setting up a hostname and root password.
If you already have a Hostinger VPS, you can install n8n anytime in one click using the OS template. Before following this procedure, back up your files because any existing data will be wiped. Here’s how to install n8n on your server:


After the installation process is complete, you can access n8n by clicking the Manage App button on the same screen. Create an account to finish the configuration.
Find the API you want to integrate with n8n. You can look for one on an API marketplace like RapidAPI or a community-curated catalog like GitHub’s Public API repository.
For testing, we recommend using a public API because it is free and easy to sign up for. In this tutorial, we’ll use Hostinger’s public API as an example.

The ideal API should have comprehensive documentation covering its specification, requirements, and potential errors to help streamline the setup process. It must also come from a reputable company or developer to ensure its safety.
After deciding on the API, access the provider’s website and obtain two essential pieces of information: its endpoint and authentication key.
An API endpoint is the URL n8n will use to interact with the API’s server and to request specific data. Meanwhile, an authentication key is a unique token that validates the n8n’s API request.
An endpoint is reserved for a specific function. If your workflow involves multiple actions or tasks, you may need to obtain multiple API endpoints, which can also come from several providers.
Depending on the API provider, the steps to obtain the API endpoint and authentication key differ. For example, here’s how to do so at Hostinger:


For security reasons, you won’t be able to see your token again after closing the API page, so be sure to save the key and testing commands before proceeding.
Testing your API endpoint is crucial to ensure it can take requests and send responses properly.
You can test an API using different methods, but the easiest way is to use the cURL command, which is preinstalled in your computer’s terminal.
To use cURL, simply open your system terminal and enter the following command. Replace API-endpoint and API-key with their actual values:
curl -X GET "API-endpoint" -H "Authorization: Bearer API-key"
Depending on the API, you may need to change the authorization method or add more information to the cURL request. If your API provider gives the testing commands, like Hostinger does, simply copy and paste them into your terminal. Otherwise, read its specification for more information.
If the API request is successful, your terminal will print data in JSON format. If you encounter an error, check the API documentation for a troubleshooting guide.

Adding an API in n8n is straightforward, as you only need to add the node and fill out the required information. Here’s how to do so:

If you have trouble filling out the fields, refer to the API and n8n documentation. Depending on your API specification, you may not need to enter all of the information above.
Although your API will be integrated with n8n after this step, it still won’t be functional because you’ll need to enable your workflow to send the API request and fetch data.
After integrating an API into your n8n instance, you’ll need to create a workflow that utilizes its capabilities to transform and process data.
Since the workflow and nodes differ depending on what you want to automate, check out our tutorial on n8n integration examples for inspiration. For this tutorial, we’ll create a simple alerting system that gives users notifications when their VPS resource usage exceeds certain thresholds.
Starting an n8n workflow requires a trigger node. There are various options for different workflow scenarios, which are classified into eight categories:
In this tutorial, we’ll use n8n’s Webhook node, one of the most flexible and easiest to configure. Because it uses a URL, you can start the node by simply opening the address in your web browser. You can also integrate the webhook into custom-coded applications without being restricted to specific platforms.
The webhook node works as is, but you can configure many settings to improve its security and usability. For example, you can set an authentication method to ensure only legitimate users can trigger it. We’ll explain more about this in the next section.
Important! n8n’s Webhook trigger node has two fields for URLs: test and production. Use them correctly based on their purposes to avoid security and functionality issues.
Creating a workflow in n8n involves connecting nodes to determine data flow and handling. In our case, the workflow plan is as follows:
The workflow diagram looks like the following on the n8n canvas:

You can expand this workflow further by connecting more nodes or workflows – it depends on the complexity of your automation goal.
For instance, you can integrate a workflow that automatically asks AI tools for performance optimization solutions, which is possible by combining MCP with n8n. Another example is that you can connect the spreadsheet node to log the history of hardware usage spikes.
Configuring logic in n8n defines how your workflow will select, manipulate, and use data to yield your desired results.
By default, raw API data contains information that might not be relevant or compatible with the subsequent node’s processing capability. Reformatting and sorting this data ensures that each node can manipulate and forward it properly.
Reading API raw data
APIs typically send responses in the JSON format, which structures data in a key-value pair like so:
[
{
"cpu_usage":
{
"unit": "%",
"usage": {
"1751494508": 1.5 }
}
}
]If we break it down, each data point is structured in a key-value pair called object like so:
{"key": value}A key has to be a string written inside quotation marks. Meanwhile, a value can be a string, a number, or an object.
In addition to the JSON format, n8n provides a schema and table view of your API data. This helps you read and process the data more easily, as you can drag and drop it into other nodes.
Manipulating API data using JavaScript
n8n lets you pass data to nodes using two methods: Fixed or Expression. Fixed means the previous node forwards a value as is, while Expression enables you to manipulate it beforehand.
Because Expression passes data dynamically, it is typically used when working with a large amount of data or frequently changing values, such as hardware usage history.
In addition to manipulating fetched data, Expression is also useful for sending a dynamic API request. For example, in the HTTP Request node, you can set a query parameter that automatically changes, like a date.
Expression in n8n is written inside a pair of double curly brackets, mostly based on the Luxon and JMESPath libraries. Here’s what it looks like:
{{ $json.object }}In our workflow, we want to set a dynamic value that takes the average of the VPS resource usage data. To do so, we add the Edit FIelds node and use the following expression:
{{ $json.cpu_usage.usage.values().average() }}Here’s a breakdown of the expression:
If we want to perform the same operation for other hardware usage metrics, simply adjust the object accordingly. For example, here’s an expression that takes the mean of RAM usage:
{{ $json.ram_usage.usage.values().average() }}
Testing your workflow is not only helpful for verifying your automation’s functionality, but also lets you check the output from each node when developing the logic. Because your data may change after passing through a node and expression, testing helps you identify which data to work on next.
To test your n8n workflow, simply hit the Save button and click Execute Workflow. Then, start your workflow based on your chosen trigger node, which in our case is calling the webhook.

If your workflow runs, you should see checkmarks on nodes and green lines between them. Double-click a node to see its input and output values, which helps you determine how to set up the next node.
Checking the functionality of nodes in the middle of your workflow might be tricky because they commonly use altered data from the previous node. This means you must configure all the previous nodes before determining the data you are working with.
To simplify the testing process, n8n lets you use mock data to simulate the input a node will take and process. You can create it by simply clicking Set mock data on a node’s output field.
Securing your n8n workflow is crucial, especially but not only if it contains private data or sensitive information. For example, if unauthorized parties know your webhook URL, they can overload it with requests, potentially causing downtime in your automation system.
Enabling authentication on the trigger node is the most essential way to secure your workflow. This ensures that only sources with valid credentials, like a key or login information, can start the workflow.
The steps to configure authentication are similar regardless of your trigger node. For instance, here’s how to do so in the Webhook node:


Now, you can only call the webhook with the correct username and password. To check whether the authentication works, open the URL in your web browser, and a pop-up asking for the login credentials should appear.
If you use another node and want to enable Bearer authentication, you must generate a token that meets n8n’s security requirements using a separate tool. There are different methods and settings to create it. For example, here’s how to make one in the Base64 format:
username:password
In addition to securing the trigger node, there are other essential security practices to safeguard your n8n-API workflow. We’ll discuss them in the following section.
Securing your API integration in n8n involves various tasks beyond enabling authentication. In addition to maintaining its safety, the performance of your self-hosted n8n instance must remain optimal to ensure the responsiveness and smooth functionality of your automation.
Here are several best practices for securing and scaling your API-integrated n8n workflow.
Creating a workflow with OneSimpleAPI makes it easy to integrate APIs with various types of functionality, like generating QR codes or taking screenshots, into your automation system. With n8n’s pre-configured OneSimpleAPI node, you can quickly connect different API features without configuring their endpoints individually.
To use OneSimpleAPI, you need to create an account and a token. Here’s how to do so:

Next, let’s add the OneSimpleAPI node to your workflow:

That’s it. Next, test your workflow to ensure the OneSimpleAPI node can receive and process data.

Integrating an API into n8n enables you to create an automation workflow for various use cases. Here are some of the most common ones:
Integrating an API into your n8n workflow enables the automation of a wide range of tasks involving data exchange with various services, including proprietary tools or software.
With API-based functionality, you can utilize complex features or data processing capabilities beyond what n8n supports. You can also combine multiple APIs in a workflow, allowing other services to use them through a single endpoint.
In addition to public APIs from external providers, you can also easily integrate various API capabilities with n8n’s built-in OneSimpleAPI node.
Given the extensive API capabilities and n8n nodes, combining these tools makes it possible to automate various tasks. We recommend checking our n8n workflow examples to learn more about what you can automate using this tool.