Build an India Gold Price App with JavaScript
Build a live India gold-rate app from INR per-gram 24K and 22K prices, with server-side caching, Indian number formatting, GST estimates, and clear limits.
Read →The real-time gold streaming questions that come up on Reddit, answered: whether a gold WebSocket exists, how the goldprice.dev XAU and XAG tick stream works end to end, and which other APIs actually offer one (most metals APIs just poll).
Every few weeks someone on r/algotrading or r/options asks a version of the same thing: is there a WebSocket for gold prices, or am I stuck polling a REST endpoint every second? The people asking are usually building a bot that needs the price the moment it moves, or a dashboard with a live XAU ticker, and hammering a REST API on a one-second loop feels wrong to them. It is wrong. Polling burns your request quota and adds half the poll interval as average latency, and it still misses whatever ticks land between two requests.
Short answer: yes, goldprice.dev pushes gold and silver ticks over a WebSocket as they print. The longer answer is which APIs offer streaming at all, because most of the dedicated gold ones don't. Both are below.
wss://api.goldprice.dev/v1/stream is a WebSocket on the Realtime Pro plan. You connect, authenticate with your key, subscribe to the symbols you want, and the server sends a frame every time the price updates. Gold (XAU-USD-SPOT) and silver (XAG-USD-SPOT) are the two live symbols today, and a single connection can hold up to eight.
A tick looks like this:
{"type":"tick","symbol":"XAU-USD-SPOT","price":"3976.379","conf":"0.829","computed_at":"2026-07-01T02:13:25Z"}
price is a decimal string, so you parse it without inheriting float rounding. conf is a confidence band on that price, tighter when the underlying sources agree and wider when they don't. computed_at is when the value was computed server-side, which is what you measure your own end-to-end latency against.
Three messages and you are streaming: connect, auth, subscribe.
import WebSocket from "ws";
const ws = new WebSocket("wss://api.goldprice.dev/v1/stream");
ws.on("open", () => {
ws.send(JSON.stringify({ action: "auth", api_key: process.env.GOLDPRICE_API_KEY }));
});
ws.on("message", (raw) => {
const msg = JSON.parse(raw);
if (msg.type === "welcome") {
// Authenticated. Now say what you want.
ws.send(JSON.stringify({ action: "subscribe", symbols: ["XAU-USD-SPOT", "XAG-USD-SPOT"] }));
} else if (msg.type === "tick") {
console.log(`${msg.computed_at} ${msg.symbol} ${msg.price}`);
}
});
ws.on("close", (code) => {
// 4401 bad/missing key, 4403 plan below Realtime Pro, 4429 connection limit.
console.error("stream closed", code);
});
On connect the server sends a welcome frame with your tier and symbol limit. After you subscribe it returns a subscribed acknowledgement plus an immediate snapshot of the last known price for each symbol, so you have something to render before the next tick lands instead of a blank field. If nothing prints for about twenty seconds, a quiet market or a weekend, you get a {"type":"heartbeat"} so you can tell the connection is alive rather than hung.
Reconnects are your job. If the socket drops, open a new one and send auth and subscribe again. That is the one step people miss: they reconnect, forget to re-subscribe, then wonder why no ticks arrive.
This is worth spelling out, because "real-time gold price API" gets used loosely and most of the results are polling with a fast refresh, not a stream. I went through the public docs of the usual names in mid-2026. Two groups fall out.
The dedicated metals APIs are almost all REST-only. GoldAPI.io, MetalpriceAPI, and Metals.dev have no WebSocket at any tier; you poll on an interval. Metals-API lists one, but only inside a custom Enterprise contract that starts around $25,000/year, with no public streaming docs, so for a normal project it isn't really on the table. Alpha Vantage covers far more than metals and is still REST-only, even on its top plan.
The APIs that do stream gold are the broad market-data platforms, where gold is one symbol among tens of thousands and streaming sits behind a higher tier:
| API | WebSocket | Gold on the WebSocket | Entry point for streaming |
|---|---|---|---|
| goldprice.dev | Yes | Yes (XAU and XAG) | Realtime Pro, $80/mo |
| Twelve Data | Yes | Yes (XAU/USD is their own docs example) | ~$191/mo (annual Pro) for real streaming credits |
| TraderMade | Yes | Yes (XAU/USD) | Paid tiers from ~£599/mo |
| Finage | Yes | Yes (XAU/USD, via the forex/CFD feeds) | Paid WebSocket from ~$299/mo |
| Polygon.io (now Massive) | Yes | Forex pairs; XAU coverage unclear in the docs | Paid currencies tier |
| Finnhub | Yes (free tier included) | Broker forex; XAU not clearly documented | Free, up to 50 symbols |
| GoldAPI.io | No | — | REST polling only |
| MetalpriceAPI | No | — | REST polling only |
| Metals.dev | No | — | REST polling only |
| Metals-API | Enterprise only | Undocumented | ~$25,000/yr custom |
| Alpha Vantage | No | — | REST polling only |
(Public docs, mid-2026. Competitor pricing and coverage move around, so check their current pages before you commit to one.)
What the table shows is a gap. If you want gold over a WebSocket, your options have mostly been either a large multi-asset platform where gold is a forex afterthought and streaming starts near $200 a month, or a metals API that makes you poll. goldprice.dev is metals-first and streams gold and silver at $80.
A WebSocket earns its place when you hold a connection open and care about sub-second moves: a live ticker, an execution screen, a bot watching for a threshold. For a job that checks the price every few minutes, the plain REST endpoint at /v1/spot/XAU-USD-SPOT is simpler and holds no socket. And if you want push without the Realtime Pro plan, the Pro tier has a Server-Sent Events stream at /v1/prices/stream; Stream live gold prices with Server-Sent Events walks through that one, which needs no WebSocket client at all.
Still weighing whether an API is worth building on? Gold price API on Reddit: the developer questions, answered covers the free tier, the limits, and where the number comes from. To start, a free key takes a minute; the WebSocket itself lives on Realtime Pro.
related guides
Build a live India gold-rate app from INR per-gram 24K and 22K prices, with server-side caching, Indian number formatting, GST estimates, and clear limits.
Read →Build a gold jewelry price calculator from live per-gram karat prices, with exact decimal math, caching, margins, and clear valuation limits.
Read →Build a reproducible local-currency gold backtest from settled XAU/USD bars and dated FX observations, without inserting future rates into historical rows.
Read →goldprice.dev
Live gold prices, historical OHLC, and multi-source aggregation — available via REST and SSE.