Skip to content
Precious metals

Gold and silver price API

Gold (XAU), silver (XAG), platinum (XPT) and palladium (XPD) per troy ounce – in any of 160+ currencies, live and historical back to 1999, in the same API as your exchange rates.

Metals4
UnitTroy ounce
HistorySince 1999
Quote inAny currency
GET /v1/latest · base XAU
# Price of one troy ounce of gold in USD, EUR and INR
curl -G "https://api.fxapi.com/v1/latest" \
  -d base_currency=XAU \
  -d currencies=USD,EUR,INR \
  -H "apikey: $FXAPI_KEY"

# Monthly average silver price in EUR for 2025
curl -G "https://api.fxapi.com/v1/average" \
  -d date_from=2025-01-01 -d date_to=2025-12-31 \
  -d base_currency=XAG -d currencies=EUR \
  -H "apikey: $FXAPI_KEY"

Precious metals have their own ISO 4217 codes – XAU for gold, XAG for silver, XPT for platinum and XPD for palladium – and in the fxapi foreign exchange rates API they work exactly like currencies. That makes fxapi a compact gold and silver price API: get the price of an ounce of gold in rupees, the monthly average silver price in euros, or the value of a bullion holding in your reporting currency, with the same endpoints and API key you use for FX rates.

Metals and units

CodeMetalUnit
XAUGold1 troy ounce
XAGSilver1 troy ounce
XPTPlatinum1 troy ounce
XPDPalladium1 troy ounce

One troy ounce is 31.1034768 grams. For per-gram or per-kilogram prices, convert in your code.

Two ways to quote metals

  • Metal as base – base_currency=XAU&currencies=USD,EUR returns the price of one ounce in each currency. This is the format most people expect.
  • Metal as target – base_currency=USD&currencies=XAU returns how many ounces one dollar buys (a small number). Invert it to get the price.

Use type=metal to return only XAU, XAG, XPT and XPD.

PHP: gold price per gram in the visitor’s currency

<?php
$currency = "EUR";
$query = http_build_query(["base_currency" => "XAU", "currencies" => $currency]);

$ch = curl_init("https://api.fxapi.com/v1/latest?$query");
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER     => ["apikey: " . getenv("FXAPI_KEY")],
    CURLOPT_TIMEOUT        => 10,
]);
$response = json_decode(curl_exec($ch), true);

$perOunce = $response["data"][$currency]["value"];
$perGram  = $perOunce / 31.1034768;

printf("Gold: %.2f %s per gram (%s)\n", $perGram, $currency, $response["meta"]["last_updated_at"]);

History, averages and change

NeedRequest
Gold price on a past date/v1/historical?date=2008-10-24&base_currency=XAU&currencies=USD
Gold price time series/v1/range with base_currency=XAU
Monthly average silver price/v1/average with base_currency=XAG
Change in platinum since January/v1/fluctuation with base_currency=XPT

Who uses metal prices from an FX API

  • Jewelry and bullion shops – show indicative metal values in the shopper’s currency and add your own premium.
  • Wealth and portfolio apps – value metal holdings next to cash and crypto.
  • Accounting – revalue metal inventory at period end with historical and average prices.
  • Content and dashboards – daily gold and silver widgets without a separate commodities subscription.

Metals follow your plan’s update interval – daily on Free, hourly on Basic and every 60 seconds on Professional and Enterprise. See pricing.

Frequently asked questions

Which precious metals are available?
Gold (XAU), silver (XAG), platinum (XPT) and palladium (XPD), each quoted per troy ounce, as defined by ISO 4217.
How do I get the gold price in USD per ounce?
Call /v1/latest?base_currency=XAU&currencies=USD. The value is the price of one troy ounce of gold in US dollars.
Can I get the gold price per gram?
Divide the per-ounce price by 31.1034768 – one troy ounce is 31.1034768 grams. For a kilogram, multiply the per-gram price by 1,000.
Is historical gold price data available?
Yes – daily data back to 1 January 1999 through /v1/historical, time series via /v1/range (Professional+), and monthly or yearly averages via /v1/average on every plan.
Is this a bullion dealer price?
No. The API returns market reference prices. Dealer buy and sell prices include premiums and spreads you would add yourself.
Free plan · no credit card

Get your free exchange rate API key

300 requests a month, latest and historical rates, fluctuation and averages – free forever. Upgrade when you need faster updates or more requests.