Build a Crypto Price Tracker App with JavaScript
Crypto prices move fast, and checking them means opening an exchange app every time. A small price tracker that pulls live prices from a free public API and shows them in a clean list is a perfect weekend project — and i
Crypto prices move fast, and checking them means opening an exchange app every time. A small price tracker that pulls live prices from a free public API and shows them in a clean list is a perfect weekend project — and it teaches you fetching, rendering, and auto-refresh in one go.
We use the free CoinGecko API, which needs no API key for basic price data:
const coins = ['bitcoin', 'ethereum', 'solana', 'dogecoin'];
async function loadPrices() {
const ids = coins.join(',');
const url = `https://api.coingecko.com/api/v3/simple/price?ids=${ids}&vs_currencies=inr&include_24hr_change=true`;
const res = await fetch(url);
const data = await res.json();
document.getElementById('prices').innerHTML = coins
.map((coin) => {
const price = data[coin].inr;
const change = data[coin].inr_24h_change.toFixed(2);
const up = change >= 0;
return `
<div class="coin">
<h3>${coin.toUpperCase()}</h3>
<p>₹${price.toLocaleString('en-IN')}</p>
<p class="${up ? 'up' : 'down'}">${up ? '▲' : '▼'} ${Math.abs(change)}% (24h)</p>
</div>`;
})
.join('');
}
loadPrices();
setInterval(loadPrices, 60000); // refresh every minute
The setInterval refreshes prices every minute, so the page stays current without a reload. The 24-hour change is colour-coded green for up and red for down, which makes the list scannable at a glance. CoinGecko's free tier allows a limited number of requests per minute, so one request per minute per user is comfortably within the limit.
You can extend this in useful directions: add a search box to track any coin, store a small portfolio (how much of each coin you hold) and show its total value, or add a price alert that highlights a coin when it crosses a level you set. A simple chart of the last 7 days, using the CoinGecko market chart endpoint, is a good next step too.
Watching prices is fun, but it is not the same as understanding investing. Before putting real money into any market, it helps to learn the basics first — the best stock market books for beginners explain how markets work, how to think about risk, and why patience beats chasing every price move.
This project is a strong beginner build because it combines a real public API, async JavaScript, formatting numbers for Indian users, and auto-refresh — all in about 40 lines of code.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.