<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Live XAU/USD Price</title>
<style>
body {
font-family: Arial, sans-serif;
background: #f4f4f4;
text-align: center;
padding-top: 50px;
}
#price {
font-size: 2em;
color: #d4af37;
}
</style>
</head>
<body>
<h1>Live Gold Price (XAU/USD)</h1>
<div id="price">Loading...</div>
<script>
const apiKey = 'b8c8f276e6214564a041b8db49f47424'; // Replace with your Twelve Data API key
const symbol = 'XAU/USD';
async function fetchPrice() {
try {
const response = await fetch(`https://api.twelvedata.com/price?symbol=${symbol}&apikey=${b8c8f276e6214564a041b8db49f47424}`);
const data = await response.json();
document.getElementById('price').innerText = `$${parseFloat(data.price).toFixed(2)}`;
} catch (error) {
document.getElementById('price').innerText = 'Error fetching price';
console.error(error);
}
}
fetchPrice();
setInterval(fetchPrice, 10000); // Refresh every 10 seconds
</script>
</body>
</html>
Live Gold Price (XAU/USD)
Loading…