Developer guide · Sri Lanka

Gold prices. One simple API.

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

Available endpoints

GET · LIVE

Latest published prices

/api/gold

Fetches the source's latest rates. Results are cached internally for 5 minutes by default. Check source_date for the publication date.

GET · LIVE

Recent source history

/api/gold/history

Latest prices plus history and count from the source's recent rate table. Multiple entries may share a date.

GET · STORED

Latest daily snapshot

/api/gold/stored/latest

Reads the most recent successful daily collection from the database. Returns 404 if no snapshot has been collected.

GET · STORED

Daily history

/api/gold/stored/history

Returns history, count, and next_before, newest first. Optional inclusive from and to dates filter the collection date.

GET · STORED

One collection date

/api/gold/stored/2026-11-06

Replace the date with a valid YYYY-MM-DD Sri Lankan collection date. Returns 404 if that day has no stored snapshot.

Make your first request

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']);

Filter and paginate history

/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.

Example stored response

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.

Understand the data

The collection date is when we scheduled the daily snapshot in Asia/Colombo. The source date is when the jeweller published the rate and may be earlier or null. Prices are returned in LKR, with the source's weight label preserved and unverified. No weight conversion is applied.

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

Errors have success: false and an error object with code and message.