Module 10Lesson 5

Lesson 5. Working with Data: HTTP Request and JSON Processing

Hands-on: n8n

Lesson 5. Working with Data: HTTP Request and JSON Processing#

Goal: learn to make HTTP requests and process the returned data.

Task#

Get the current Bitcoin (BTC) price in USD via API and send it to Telegram.

Step 1. Find an API for Cryptocurrency Prices#

We'll use the free API: CoinGecko

Endpoint:



GET https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd


Response:



{


  "bitcoin": {


    "usd": 45000


  }


}


Step 2. Create a New Workflow#

  1. Create a new workflow: "Bitcoin Price"

  2. Add a Manual Trigger node (for manual start)

Step 3. Add HTTP Request Node#

  1. Click "+" to the right of Manual Trigger

  2. Find the HTTP Request node

  3. Configure the request:

    • Method: GET

    • URL: https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd

  4. Click "Execute Node" → you'll get a JSON response

Step 4. Process the Data (Extract Price)#

  1. Click "+" to the right of HTTP Request

  2. Find the Set node

  3. Configure the field:

    • Name: price

    • Value: {{ $json.bitcoin.usd }}

  4. Click "Execute Node" → you'll see the price field with the Bitcoin price

What is {{ $json.bitcoin.usd }}?

This is an n8n expression that extracts a value from JSON:

  • $json — data from the previous node

  • .bitcoin.usd — path to the usd field inside bitcoin

Step 5. Send the Price to Telegram#

  1. Click "+" to the right of the Set node

  2. Add the Telegram node (configure credentials if not done yet)

  3. Configure the message:

    • Chat ID: your Chat ID

    • Text: Current Bitcoin price: ${{ $json.price }} USD

  4. Click "Execute Node" → you'll receive a message in Telegram:



Current Bitcoin price: $45000 USD


Step 6. Save the Workflow#

Click "Save".

Done! Now you can manually run the workflow and get the current Bitcoin price.

Bonus: add a Cron node at the start of the workflow to get the price automatically every hour.