Latest published prices
/api/goldFetches the source's latest rates. Results are cached internally for 5 minutes by default. Check source_date for the publication date.
Read published 22K and 24K gold prices in Sri Lankan rupees, or explore daily snapshots collected at 4:00 a.m. Sri Lanka time.
Explore endpoints · Usage examples/api/goldFetches the source's latest rates. Results are cached internally for 5 minutes by default. Check source_date for the publication date.
/api/gold/historyLatest prices plus history and count from the source's recent rate table. Multiple entries may share a date.
/api/gold/stored/latestReads the most recent successful daily collection from the database. Returns 404 if no snapshot has been collected.
/api/gold/stored/historyReturns history, count, and next_before, newest first. Optional inclusive from and to dates filter the collection date.
/api/gold/stored/2026-11-06Replace the date with a valid YYYY-MM-DD Sri Lankan collection date. Returns 404 if that day has no stored snapshot.
Use this website's origin as your API base URL. No API key is required. All API endpoints return JSON and support GET, HEAD, and OPTIONS.
// Run from this website's origin, or use its full URL.
const response = await fetch('/api/gold/stored/latest');
const data = await response.json();
if (!response.ok) throw new Error(data.error.message);
console.log(data.prices['22K'], data.prices['24K']);
/api/gold/stored/history?from=2026-11-01&to=2026-11-30&limit=30
Dates must be valid calendar dates; from must not be after to. Both bounds are optional. The default limit is 30, with a maximum of 100. When next_before is not null, pass that value as before on the next request, keeping the same filters. The cursor is exclusive. An empty range returns 200 with an empty history.
Illustrative values only:
{
"success": true,
"collection_date": "2026-11-06",
"source_date": "2026-11-05",
"currency": "LKR",
"prices": { "22K": 338600, "24K": 368000 }
}
Stored responses also include timezone, UTC scheduled_at and fetched_at timestamps, source details, unit, extraction method, and warnings.
Daily snapshots appear after successful collection. Failed collections can leave gaps. Live endpoints may show newer rates than the daily archive. The homepage is this guide; use /api/gold for live JSON.
Errors have success: false and an error object with code and message.