goldprice.dev — price alerts (Free-tier friendly)
Poll the spot price, compare to a threshold, notify. Runs on the Free tier (free key, no card): 30 req/min, 1,000 req/mo.
Poll the spot price
curl -H "Authorization: Bearer ga_live_..." \
"https://api.goldprice.dev/v1/spot/XAU-USD-SPOT"
Response (values are strings; symbol is the base only):
{"symbol":"XAU","quote_currency":"USD","unit":"troy_ounce","contract_type":"spot","price":"4165.16","bid":"4167.03","ask":"4163.28","is_stale":false,"computed_at":"2026-07-07T13:12:19Z"}
Compare float(price) to your threshold; notify on crossing. bid/ask carry the spread if you need it.
Two rules that keep alerts correct
- Respect
is_stale. Never fire (or clear) an alert on a row whereis_staleistrue— you'd alert on a frozen price. For provenance, add?include=sourcesto see each source's ownis_stale,fetched_at, andsource_timestamp. - Budget your polls against the quota. 1,000/mo ≈ one poll every ~43 min if run continuously. Poll only during the hours you care about, cache the last value, and dedupe repeat notifications. Physical ($10) raises this to 20k/mo, Pro ($30) to 100k/mo when you need tight cadence.
Sketch
import time, httpx
THRESHOLD, last = 3400.0, None
while True:
r = httpx.get("https://api.goldprice.dev/v1/spot/XAU-USD-SPOT",
headers={"Authorization": "Bearer ga_live_..."}).json()
if not r["is_stale"]:
price = float(r["price"])
if last is not None and (last < THRESHOLD <= price or last > THRESHOLD >= price):
notify(f"gold crossed {THRESHOLD}: {price}")
last = price
time.sleep(300) # 5 min: inside the 30/min rate limit. But continuous
# 5-min polling is ~8.6k/mo — over Free's 1k/mo. On Free,
# run only during your alert window; ~hourly fits 1k/mo.
Divergence alerts (no key)
Alert when sources disagree — a data-quality signal:
curl "https://api.goldprice.dev/v1/prices/divergence?threshold=50"
Anonymous returns a count; authenticated returns per-symbol detail (tier-filtered). threshold is in basis points.
When to upgrade
Higher poll cadence → Physical/Pro quota. Silver/copper alerts (XAG/HG) → Pro. Sub-second reaction → Realtime Pro ($80) WebSocket stream instead of polling (see the realtime docs at https://goldprice.dev/docs/stream).