Retrieving Data from External APIs
1. Retrieving Data from External APIs
In Chapter 1, we used the HTTP Request node to send POST requests between our own workflows. But in the real world, most of the data your automations need lives outside n8n — in external APIs.2. API Requests: GET and POST
Weather data, stock prices, customer records, and shipping statuses are all frequently shared and accessed via APIs. And the way you retrieve that data is with HTTP GET requests. GET is the default method of the web — every time you load a webpage, your browser sends a GET request. Unlike POST, which sends data to a server, GET asks the server to send data back to us. In this video, we're going to use the HTTP Request node in GET mode to pull live data from a public weather API.3. Anatomy of an API URL
Every API URL has a structure. The base URL identifies the service. Path parameters — the part before the question mark — specify what we're asking about, like a city name. Query parameters — the key-value pairs after the question mark — control how the data comes back. When we combine these with the HTTP method, we have everything needed to talk to any API. The one we'll use is wttr.in — a free weather service that doesn't require signing up or creating an API key.4. Fetching Weather Data
We start a new workflow with a Manual Trigger, then add an HTTP Request node. We set the Method to GET and paste in the API URL. Executing it, we get back a nested JSON structure in the Output panel — a current_condition field with temperature, humidity, and weather descriptions, plus weather with multi-day forecasts. You'll notice notation like current_condition[0] — what is that 0 in square brackets? current_condition is an array — a numbered list of items where each entry has a position starting from zero. The [0] means "get the first item from this array." Many API fields come back as arrays even when there's only one value, so [0] grabs that entry. The key skill here is learning to navigate this structure and find the fields we actually need.5. Customizing and Extracting
Most APIs let us customize what we get back using query parameters. With wttr, format=j1 tells it to return JSON. But we can add more. We can change the city by modifying the path — replacing London with Tokyo. And we can add query parameters using n8n's parameter fields — adding the "lang" key with value "fr" returns weather descriptions in French instead of English. Once we've got the data, the next step is extracting only the fields we need. The wttr response is deeply nested — the current temperature is buried inside current_condition[0].temp_C. We're not going to pass that whole blob downstream. Instead, we'll add an Edit Fields node to pull out specific values — city, temperature, humidity, and description — into a clean, flat structure. This extract-and-flatten pattern6. Let's practice!
is something we'll use every time we work with an external API.Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.