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#
-
Create a new workflow: "Bitcoin Price"
-
Add a Manual Trigger node (for manual start)
Step 3. Add HTTP Request Node#
-
Click "+" to the right of Manual Trigger
-
Find the HTTP Request node
-
Configure the request:
-
Method: GET
-
URL:
https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd
-
-
Click "Execute Node" → you'll get a JSON response
Step 4. Process the Data (Extract Price)#
-
Click "+" to the right of HTTP Request
-
Find the Set node
-
Configure the field:
-
Name:
price -
Value:
{{ $json.bitcoin.usd }}
-
-
Click "Execute Node" → you'll see the
pricefield 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 theusdfield insidebitcoin
Step 5. Send the Price to Telegram#
-
Click "+" to the right of the Set node
-
Add the Telegram node (configure credentials if not done yet)
-
Configure the message:
-
Chat ID: your Chat ID
-
Text:
Current Bitcoin price: ${{ $json.price }} USD
-
-
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.