Crypto Price Tracker with HTML, CSS & JavaScript
30 DAYS 30 PROJECT CHALLENGE
Day #24
Project Overview
A Crypto Price Tracker built using HTML, CSS, and JavaScript that allows users to view real-time cryptocurrency prices.
The application fetches live market data from a public crypto API and displays current prices in multiple currencies, helping users quickly track popular cryptocurrencies.
Key Features
- Fetches real-time cryptocurrency prices.
- Supports multiple popular cryptocurrencies.
- Displays prices in USD and INR.
- Uses a public API with no authentication required.
- Instant updates without page reload.
- Clean, responsive, and user-friendly interface.
- Suitable for learning API integration and async data handling.
HTML Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Crypto Price Tracker</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="crypto-container">
<h2>Crypto Price Tracker</h2>
<select id="cryptoSelect">
<option value="bitcoin">Bitcoin</option>
<option value="ethereum">Ethereum</option>
<option value="tether">Tether</option>
<option value="binancecoin">Binance Coin</option>
<option value="ripple">Ripple</option>
</select>
<button onclick="getPrice()">Get Price</button>
<div class="result" id="result"></div>
</div>
<script src="script.js"></script>
</body>
</html>
CSS Code
* {
box-sizing: border-box;
font-family: "Segoe UI", sans-serif;
}
body {
min-height: 100vh;
background: #042453;
display: flex;
justify-content: center;
align-items: center;
}
.crypto-container {
background: #ffffff;
width: 320px;
padding: 25px;
border-radius: 14px;
text-align: center;
box-shadow: 0 20px 40px rgba(0,0,0,0.25);
}
h2 {
margin-bottom: 15px;
}
select {
width: 100%;
padding: 10px;
border-radius: 6px;
border: 1px solid #ccc;
margin-bottom: 10px;
}
button {
width: 100%;
padding: 10px;
border: none;
border-radius: 6px;
background: #4f46e5;
color: white;
cursor: pointer;
}
.result {
margin-top: 15px;
font-size: 14px;
font-weight: 600;
}
.error {
color: red;
}
Javascript Code
const result = document.getElementById("result");
function getPrice() {
const crypto = document.getElementById("cryptoSelect").value;
result.innerHTML = "Loading...";
fetch(
`https://api.coingecko.com/api/v3/simple/price?ids=${crypto}&vs_currencies=usd,inr`
)
.then(res => res.json())
.then(data => {
const usd = data[crypto].usd;
const inr = data[crypto].inr;
result.innerHTML = `
💰 <strong>${crypto.toUpperCase()}</strong><br>
USD: $${usd}<br>
INR: ₹${inr}
`;
})
.catch(() => {
result.innerHTML = `<p class="error">Error fetching price</p>`;
});
}
Related Projects
Day 22 : News App
Displays latest news headlines dynamically based on search input.
Concepts: Async data handling, dynamic UI rendering.
Day 26 : Job Search App (API)
Searches and displays job listings dynamically using a public jobs API.
Concepts: API integration, async data fetching, dynamic UI rendering.
Day 27 : Recipe Finder App
Searches and displays recipes dynamically using a public food API.
Concepts: API integration, async data fetching, dynamic UI rendering.