2 Working with APIs with HAILogo
This tutorial connects n8n to real-world data sources through APIs, walking through X (Twitter) developer credentials, OAuth2 setup, and a working HTTP request workflow.
An automation workflow is only as useful as the real-world data flowing into it, and for most projects that means connecting to an API. This tutorial, part of the Madison framework series, walks through exactly how to do that in n8n: authenticating with an external API and pulling live data into a workflow you build yourself.
Choosing the right APIs for your project
Before touching any code or credentials, the video makes the case for picking APIs deliberately rather than defaulting to whatever's easiest. The recommendation is to use at least two to three data sources relevant to your specific problem. For a brand analysis project, that might mean the YouTube Data API, the Twitter/X API, or web scraping tools. For market research, product review APIs, Google Trends, or price comparison sites fit better. For a customer service project, support ticket databases or FAQ scraping make more sense. The underlying principle is the same across all of them: pick sources that provide data directly relevant to the problem you're actually trying to solve, not just whatever API happens to have good documentation.
Getting credentials from the X developer portal
Most APIs require authentication, and the video demonstrates the process using the X (Twitter) API as a concrete example, noting that the steps are similar for most other services. The starting point is developer.x.com, where you sign up and create a developer account. Once inside, a default project already exists. From there, you go to Settings, scroll to the user authentication setup section, and click Setup if it hasn't been configured yet. The required changes are: app permissions set to read and write, and app type set to web app. For the app info, the callback URI needs to point back to your local n8n instance, since that's where the OAuth exchange will actually land. After entering the same callback URI for both OAuth 2 and OAuth 1 and saving, X generates a client ID and secret key, which also appear again under the Keys and Tokens section.
One security point the video calls out directly: never share your API keys or commit them to public repositories.
Wiring the credentials into n8n
Back in a local n8n instance, adding the credential is a matter of clicking the plus icon, selecting Credential, and searching for X. The recommended, tried-and-tested method is OAuth2 API. After pasting in the client ID and secret key from the developer portal and clicking "connect my account," n8n prompts you to authorize the app. Once authorized, a new credential appears in the list, ready to be used inside any workflow.
Building a workflow that pulls real data
With credentials in place, the tutorial builds an actual workflow from scratch: a new workflow named "API collection," starting with a manual trigger node, followed by an HTTP Request node. The HTTP Request node is configured with the method set to GET and an endpoint URL, in this case a request to the X API for public profile information about a specific account (OpenAI is used as the example). That endpoint returns structured JSON data about the user, including their user ID, name, username, and profile description. For authentication, the node is set to "predefined," with the credential type set to the OAuth2 credential configured earlier. Running the node confirms the connection works, returning output in both JSON and table format.
For larger datasets, like collections of tweets or reviews, the video notes you'd typically follow up with a JSON Parse node and save the result using a Write Binary File node, though that step isn't needed for a small single-profile lookup like the one demonstrated.
Combining multiple data sources
Since a useful project needs at least two to three data sources, the video closes by covering two ways to combine APIs in a single workflow. The first is running parallel branches directly off the trigger node, adding a second HTTP Request node alongside the first so both calls fire independently. The second is sequential: using the result of one API call to inform the next, for example getting a list of products from one API and then looping through those products to pull detailed reviews from another. A Merge node is used to combine data from multiple sources into a single dataset before saving it.
Key takeaways
- Choose two to three APIs that are directly relevant to your specific project problem, rather than defaulting to convenient sources.
- Get credentials from the provider's developer portal (developer.x.com for X), setting app permissions to read and write and app type to web app.
- Never share API keys or commit them to public repositories.
- In n8n, add credentials via the plus icon, searching for the service, and using the OAuth2 API method.
- Build a workflow with a manual trigger and an HTTP Request node, set to GET, using the predefined OAuth2 credential for authentication.
- Combine multiple APIs either with parallel branches off the trigger or sequentially, feeding one API's output into the next, then use a Merge node to unify the data.
- Aim for at least 50 to 100 records of collected data, and document your data sources.
Try it yourself
If you're building your own n8n project, start by picking two to three APIs relevant to your specific problem, generate credentials from each provider's developer portal, and wire them into n8n using the OAuth2 credential method shown here. The next video in this series covers cleaning and structuring the collected data and handling errors that come up during collection.
Full transcript(auto-generated, with timestamps)
[0:00]Hello everyone, welcome back to Madison framework tutorial series. I'm Kiti and today we are going to connect NAN to real world data sources through APIs. By the end of this video, you will know how to authenticate with APIs and pull in the data you need for your Madison agent. Before we dive into the technical setup, let's talk about choosing the right APIs for your Madison project. You need to use at least two to three data sources relevant to your specific problem. For brand analysis project, consider YouTube data API, Twitter API or web scraping tools. For market research, look at product review APIs, Google trends or price comparison sites.
[0:34]For customer service projects, support ticket databases or FAQ scraping would be appropriate. The key is selecting the sources that provide data directly relevant to your problem statement. Now, I will demonstrate how to generate an API key from the developer portal. Most APIs require authentication. Let's go through the process of setting up credentials in NAT. First, you will need to create an account with your chosen API provider and generate API keys from their developer portal. For this example, I will demonstrate with a Twitter API, but the process is similar for most of the services. And a security tip here is never share your API keys or commit them to public
[1:14]Repositories. You can just Google Twitter developer account and you'll land on this. There is extensive documentation available in this link and the developer portal link is developer.x.com. Sign up and create your account. Once you are here, you see a default project that is already created. So go to the settings, click on this settings button and scroll down. You see this user authentication setup. So I just did the authentication. So it's already set up. But initially you will see a setup button here. Click on it and change these permissions. This should be app permissions should be read and write and type of app should be web app. And for app info the URI call
[2:01]Back URI is the call back from your local host NA10. So this is the credential. You will see that in the NA 10 in the next section that I'm going to show it for now. You can copy paste this. The same thing for OOTH 2 and OOTH 1 and just click on the save button and then you will see client ID and secret key generated. Come to this keys and token section. Scroll down and yes you're going to see the same thing here again. Next step is adding these credentials in your local NAN. Let's do that and open your local host NA10 and click on this
[2:39]Plus icon. For now we are creating a new credential. So click on credential and search for X. So this is a tried and tested method. So select O2 API and click on continue. Copy paste the same client and secret key here. Yes, I have copy pasted my client ID and secret key and I'll click on this connect my account. It's asking to authorize app and yes connection successful. That's it. And you can see a new credentials a new credential is being added here. Now let's build a workflow that connects to an API and pulls data. create a new workflow and let's name it API collection
[3:32]And start uh creating the new workflow by adding the first step that is manual trigger and after this let's add an HTTP request node search for HTTP request and configure it to your API set the request method to get and enter the endpoint URL. Here we are making a simple get request to the Twitter API to fetch the public profile information about a specific Twitter account in this case OpenAI. So this endpoint returns structured JSON data about user including their user ID, name, username, profile description etc. For the authentication, select predefined. The credential type should be XO2 because that is the one that we have
[4:26]Already configured. And uh yeah, this is already set up now. So yeah, that's it. And let's go back to the canvas. I will test this connection by running this node. Yep, it is executed successfully. And you can see the output here in the JSON format and also in the table. So as you are receiving the JSON data back, congrats, you have successfully connected to an API. Now if we are working with larger data sets like tweet results or reviews, then we would structure this the JSON using JSON parse node and saving it using a right binary file. But for this particular small user profile lookup,
[5:14]I'm not going to do going to be doing that. And as a next step, you need at least two to three data sources. So let's quickly see how to combine multiple APIs in one single workflow. What you can do is you can actually add parallel branches from your trigger node. So let's select another HTTP. For now, I'm just going to leave it as it is and add another node. You can do this or alternatively you can use the result from one API call to inform your next API call creating a sequential workflow. Yes, something like this. For example, you might first get a list of products from one API and then loop
[5:59]Through those products to get the detailed reviews from another API. And you can also know use a a merge node and this is useful for combining data from multiple sources into one data set before saving it. You now know how to connect NA to APIs and collect real world data for your Madison project. In the next video, we'll look at cleaning and structuring that data and handling errors that might occur during the collection. Remember, we are focusing on getting relevant data and meaningful analysis. So aim for at least 50 to 100 records but more is better and please document your data sources as required. Up next is data cleaning and error
[6:41]Handling in NAN. Thank you for watching this video.
More videos
2:08Bridging the Pixel Gap in Browser Automation.
2:23How One Narrow Safety Rule Can Make an AI Less Safe Everywhere Else.
2:04Why splitting a chunk from its document makes it retrieve for the wrong question
4:20Three You Can Take Back. One You Can't.
2:21Why a 50-turn agent pays for the same screenshot 35 times unless it caches the pixels
1:53