Live Bitcoin Price Tracker
·1 min read·By Crypto Team
bitcoincryptolive-data
Live Bitcoin Price Tracker 📈
This post demonstrates fetching and displaying live cryptocurrency data in MDX!
Current BTC/USD Price
Bitcoin Price (Live)
Loading historical data from CoinGecko...
Fetching real Bitcoin price history...
How It Works
- API Source: Uses CoinGecko's public API (
https://api.coingecko.com/api/v3/simple/price) - Update Frequency: Fetches new price every 15 seconds
- Chart History: Keeps last 10 data points with equal spacing
- No API Key Required: This is a public endpoint
The Code
Here's how simple it is to fetch live data:
const response = await fetch('https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd')
const json = await response.json()
const usdPrice = json.bitcoin.usdThe chart will update automatically as new prices come in. Leave this page open to see the Bitcoin price change over time!
Other Cryptocurrencies
You could easily modify this to track:
- Ethereum (ETH)
- Cardano (ADA)
- Dogecoin (DOGE)
- Any currency supported by CoinGecko
Just change the ids parameter in the API call!