Getting Started with MetalAPI
Create a free account, get your API key and make your first request for live gold, silver, platinum and palladium prices.
Introduction
MetalAPI is a JSON REST API for spot precious metals, industrial metals, energy, around 55 currencies and 13 cryptocurrencies. It serves real-time quotes, daily history back to 1999, conversions, OHLC bars and gold prices by karat.
Every endpoint is a plain HTTPS GET request under https://metalapi.com/api/v1, so it works from any language or HTTP client. This guide takes you from sign-up to your first response in a few minutes.
Get your API key
Create a free account with your email address. No credit card is required. The Free plan includes 100 requests per month with daily price updates, which is enough to try the API.
Open API keys in the dashboard and create a key. Keys start with mk_live_ followed by 32 characters. We only store a hash of each key, so the full key is shown once. Copy it into your password manager or environment variables straight away.
Make your first request
Request the latest prices of the four precious metals in US dollars. Replace YOUR_API_KEY with your key:
curl "https://metalapi.com/api/v1/latest?api_key=YOUR_API_KEY&base=USD¤cies=XAU,XAG,XPT,XPD"Understand the response
base is the currency the prices are expressed in (default USD). currencies limits the response to the symbols you need. Leave it out to receive every symbol in one response. A successful call returns JSON like this:
{
"success": true,
"timestamp": 1792713600,
"date": "2026-10-23",
"base": "USD",
"rates": {
"XAU": 0.0002501319446,
"USDXAU": 3997.89,
"XAG": 0.01853911754,
"USDXAG": 53.94,
"XPT": 0.000620212733,
"USDXPT": 1612.35,
"XPD": 0.0006775985906,
"USDXPD": 1475.8
},
"rate_limit": {
"limit": 100,
"remaining": 99,
"reset": 1793491200,
"used": 1,
"plan": "Free",
"reset_date": "2026-11-01T00:00:00.000Z"
}
}Every symbol appears twice. USDXAU is the price of one troy ounce of gold in the base currency, which is usually the number you want to display. XAU is the inverse: how many troy ounces one US dollar buys. The Data formats guide explains both directions in detail.
The rate_limit block, also sent as X-RateLimit-* headers, shows how much of your monthly quota is left and when it resets.
Call it from code
Here is the same request from JavaScript (Node.js 18+, Deno or Bun). This time the key is sent in a header instead of the URL:
const res = await fetch("https://metalapi.com/api/v1/latest?currencies=XAU,XAG", {
headers: { Authorization: `Bearer ${process.env.METALAPI_KEY}` },
});
const data = await res.json();
if (!data.success) throw new Error(`${data.error.code}: ${data.error.info}`);
console.log("Gold, USD per troy ounce:", data.rates.USDXAU);Next steps
- Authentication: header-based keys and domain-restricted keys for browser use.
- Available endpoints: historical rates, conversion, time series, OHLC and karat prices.
- Rate limits & plans: quotas, per-minute limits and update intervals.
- Error handling: error codes and a sensible retry strategy.
Related guides
Ready to start building?
Create a free account to get your API key, or explore every endpoint in the API reference.