Create a BTC/ETH Price & USD Exchange Rate API with CoinGecko & ExchangeRate-API
π Crypto + FX Micro-API (Webhook JSON)
π Overview Spin up a tiny, serverless-style API from n8n that returns BTC/ETH prices & 24h changes plus USDβEUR and USDβNGN from public, no-key data sources. Ideal for dashboards, low-code apps, or internal tools that just need a simple JSON feed.
βοΈ How it works
Webhook (GET /crypto-fx) β entrypoint for your client/app.
HTTP: ExchangeRate-API β USD-base FX rates (no API key).
HTTP: CoinGecko β BTC/ETH prices + 24h % change (no API key).
Merge β combines payloads.
Code (v2) β shapes a clean JSON:
btc.price, btc.change_24h
eth.price, eth.change_24h
usd_eur, usd_ngn, ts (ISO timestamp)
Respond to Webhook β returns the JSON with HTTP 200.
π Setup Guide
- Webhook path & URL In the Webhook node, confirm HTTP Method = GET and Path = crypto-fx. Use the Test URL while building; switch to Production URL for live usage.
- Test the endpoint Curl: curl -s https://<your-n8n-host>/webhook/crypto-fx Browser / fetch(): fetch('https://<your-n8n-host>/webhook/crypto-fx') .then(r => r.json()) .then(data => console.log(data))
- Response mapping (already wired) Respond to Webhook β Response Body is set to {{$json}}. The Code node outputs the exact JSON structure shown above, so no extra mapping is required.
π Security (recommended) Add a Webhook Secret (query header check in Code node) or IP allowlist via your reverse proxy. If embedding in public sites, proxy through your backend and apply rate-limit/cache headers there.
π Usage ideas Frontend dashboards (Chart.js, ECharts). HomeAssistant / Node-RED info panels. Google Apps Script to store the JSON into Sheets on a timer.
π Customization More coins: extend CoinGecko ids= (e.g., bitcoin,ethereum,solana). More FX: read additional codes from fx.rates and add to the payload. Timestamps: convert ts to your preferred timezone on client side. CORS: if calling from browsers, add CORS headers in Respond (options β headers).
π§© Troubleshooting Empty/partial JSON: run the two HTTP nodes once to verify responses. 429s / rate limiting: add a short Wait node or cache outputs. Wrong URL: ensure youβre using Production URL outside the n8n editor. Security errors: if you add a secret, return 401 when itβs missing/invalid.
Related Templates
USDT And TRC20 Wallet Tracker API Workflow for n8n
Overview This n8n workflow is specifically designed to monitor USDT TRC20 transactions within a specified wallet. It u...
Automate Daily Keyword Research with Google Sheets, Suggest API & Custom Search
Who's it for This workflow is perfect for SEO specialists, marketers, bloggers, and content creators who want to automa...
Bulk Automated Google Drive Files Sharing and Direct Download Link Generation
This N8N workflow automates the process of sharing files from Google Drive. It includes OAuth2 authentication, batch pro...
π Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments