Fetch and Parse API Data in n8n

Difficulty
1/10
Tags
http-requestapiexpressionsjson

APIs are like waiters at a restaurant — they take your request (order) to the application (kitchen) and bring back a response (your food).

In this challenge, you'll fetch data from a public API that returns random user profiles and extract specific fields from the response.

What you'll practice:

  • HTTP Request node basics
  • Understanding GET requests and URLs
  • Parsing nested JSON response data
  • Using expressions to transform data

Hints

  1. Use an HTTP Request node with GET method to fetch from https://randomuser.me/api/
  2. Add an Edit Fields (Set) node to extract and transform the data
  3. The API returns data nested inside a results array — access results[0] to get the user
  4. Name fields are at results[0].name.first and results[0].name.last
  5. Country is under location, age is under dob

Constraints:

  • Use HTTP Request node (not Code node) to fetch data
  • Use Edit Fields node to transform output
  • Final output should only contain the four required fields

Explanation

This challenge introduces the fundamentals of working with APIs in n8n.

Key concepts demonstrated:

  • HTTP Request node: Configured with GET method and the API URL
  • JSON parsing: The API returns nested data that must be navigated using dot notation
  • Expressions: Used in the Edit Fields node to extract and combine data
  • Data transformation: Converting a complex API response into a clean, flat structure

The solution uses expressions like:

  • {{ $json.results[0].name.first + " " + $json.results[0].name.last }} or even simpler {{ $json.results[0].name.first }} {{ $json.results[0].name.last }} for full_name
  • {{ $json.results[0].email }} for email
  • {{ $json.results[0].location.country }} for country
  • {{ $json.results[0].dob.age }} for age

Login to see the exercise

Create an account to access challenges and track your progress.

Log in to see exercise