Palladium Price API: XPD as JSON
You need to show or consume the live USD price of palladium (XPD) in your product—whether that’s an order ticket, a live P&L, an ERP cost sheet, or a research dashboard—and you want a clean JSON response that can be wired into your app with minimal glue code. By the end of this article, you’ll request XPD over a simple REST call, read the right field for USD per troy ounce, understand how to backfill and cache, and avoid common unit and base-currency pitfalls.
What you’re building: XPD in USD per troy ounce, ready to render
Metals-API returns palladium as ISO 4217 XPD (one troy ounce) through a straightforward endpoint. When you call GET /api/latest with base=USD and symbols=XPD, you receive two ways to interpret the price:
- rates.XPD: ounces per 1 USD (a reciprocal form)
- rates.USDXPD: USD per ounce (already in the display-friendly format most UIs expect)
For most applications that need a human-readable quote—“palladium is N dollars per ounce”—you’ll use rates.USDXPD. If rates.USDXPD is absent, you can compute USD per ounce as 1 / rates.XPD (provided rates.XPD is present and nonzero). Do not mix ISO XPD with any non-ISO codes; stick to the symbols defined by Metals-API.
Quick start with the Latest endpoint
The Latest endpoint gives you a single JSON snapshot suitable for real-time display, pricing checks, or streaming scenarios where you periodically refresh the quote. The request below targets palladium with base USD and symbol XPD.
curl "https://metals-api.com/api/latest?access_key=YOUR_KEY&base=USD&symbols=XPD"
The JSON below is the official Latest response from the documentation. The timestamp and numbers reflect that specific sample. Use it to understand the structure; when you run the same request with your key, you’ll receive today’s values.
{
"success": true,
"timestamp": 1519296206,
"base": "USD",
"date": "2018-09-10",
"rates": {
"XPD": 0.00084781687155574,
"USDXPD": 1179.5000000000057
}
}
What the fields mean and how to use them
The fields you’ll actually read in code include:
- success: Boolean. true means the request was processed; false indicates an error—check the error object if present.
- timestamp: Server-side timestamp for the data payload. Use it to label the print, cache intelligently, and detect stale snapshots.
- base: The base currency you requested (USD in this case). All rates are expressed relative to this base.
- rates.XPD: Ounces per 1 USD (reciprocal form). If you need USD per ounce, invert it.
- rates.USDXPD: USD per ounce (direct form). Prefer this value when it’s present to avoid manual conversion.
In most UI flows, you’ll display rates.USDXPD. Keep rates.XPD as a fallback: USD per ounce = 1 / rates.XPD.
Code you can paste: parse USD per ounce for XPD
Below is a minimal JavaScript example that calls the same Latest endpoint and reads rates.USDXPD, falling back to inverting rates.XPD if necessary. It also handles error cases and missing values defensively.
/**
* Fetches USD per ounce for palladium (XPD) from Metals-API.
* - Uses base=USD&symbols=XPD
* - Prefers rates.USDXPD
* - Falls back to 1 / rates.XPD if needed
*/
async function fetchPalladiumUsdPerOunce() {
const params = new URLSearchParams({
access_key: 'YOUR_API_KEY',
base: 'USD',
symbols: 'XPD'
});
const url = `https://metals-api.com/api/latest?${params.toString()}`;
const res = await fetch(url, { method: 'GET' });
if (!res.ok) {
throw new Error(`HTTP ${res.status} while requesting Metals-API Latest`);
}
const json = await res.json();
// Handle API-level error
if (json && json.success === false) {
const code = json.error && json.error.code ? json.error.code : 'unknown_error';
const info = json.error && json.error.info ? json.error.info : 'No error info provided';
throw new Error(`Metals-API error: ${code} - ${info}`);
}
// Pull direct USD per ounce if present
let usdPerOunce = json && json.rates && json.rates.USDXPD;
// Fallback: invert ounces per USD to USD per ounce
if ((usdPerOunce === undefined || usdPerOunce === null) && json && json.rates && json.rates.XPD) {
const ouncesPerUsd = json.rates.XPD;
if (typeof ouncesPerUsd === 'number' && ouncesPerUsd > 0) {
usdPerOunce = 1 / ouncesPerUsd;
}
}
if (typeof usdPerOunce !== 'number' || !isFinite(usdPerOunce)) {
throw new Error('Could not determine USD per ounce for XPD from the Latest response.');
}
return {
usdPerOunce,
base: json.base,
timestamp: json.timestamp
};
}
// Example usage
fetchPalladiumUsdPerOunce()
.then(({ usdPerOunce, base, timestamp }) => {
console.log(`XPD: ${usdPerOunce} ${base}/oz @ ${timestamp}`);
})
.catch(err => {
console.error('Metals-API request failed:', err);
});
Symbols, units, and how to read them correctly
Before you wire the value into pricing or analytics, double-check that you’re using the correct symbol and unit:
| Symbol | What it represents | How to interpret the number | Typical UI use |
|---|---|---|---|
| XPD | Palladium (ISO 4217) | rates.XPD is ounces per 1 USD when base=USD | Usually invert to display USD/oz if USDXPD is missing |
| USDXPD | USD per ounce of palladium | rates.USDXPD is already USD per ounce | Directly display this as your price print |
Metals-API uses troy ounces for precious metals. If your app displays grams or kilograms, convert after reading USD per ounce. To avoid confusion, do not mix ISO symbols with non-ISO or venue-specific codes. You can browse supported codes here: Symbols.
Going live in four steps
- Register for an API key. Copper Monthly starts at $19.99/mo. There is no Free Trial.
- Copy your access_key from the dashboard.
- Call /api/latest with base=USD and symbols=XPD using your key.
- Render rates.USDXPD as your USD per ounce palladium price.
Backfilling and updating: daily and intraday
Beyond the Latest snapshot, you’ll often need history—for charts, backtests, or audit trails. Metals-API provides:
- GET /api/timeseries — a daily window you can use to populate trend charts or backfill valuations.
- GET /api/intraday — hourly candles, one symbol per call, for finer-grained monitoring or alerting.
Use the same key and the same symbol (XPD). Keep the base currency consistent (e.g., base=USD) if you want a continuous USD series without currency conversion steps in your app. When rendering, label each point with the timestamp provided by the API.
If you need to understand Metals-API’s consolidated price methodology and sources, review the MCP page.
Production details that save time
Base currency and inversion logic
With base=USD and symbols=XPD, you’ll receive both reciprocal and direct forms:
- Prefer rates.USDXPD for display and downstream pricing in USD.
- If rates.USDXPD is missing, compute USD per ounce as 1 / rates.XPD. Guard against zero or missing values to avoid divide-by-zero or NaN issues.
Units: troy ounces vs grams
Precious metals are quoted in troy ounces. If you price in grams (e.g., jewelry SKUs), convert after reading USD per ounce. Keep conversions explicit and centralized so every component uses the same factor and rounding.
Timestamps and timezone
Use the timestamp field from the response to tag the quote in logs and your UI. Treat timestamps as authoritative for caching and staleness checks. Align your charts and alerting with these timestamps to avoid off-by-one-day issues around market hours.
Caching strategy
- Cache the Latest response for a short TTL if your UI auto-refreshes. This reduces duplicate requests while keeping quotes fresh.
- Invalidate cache when a new timestamp is observed. If the timestamp hasn’t changed, keep the current display to prevent flicker.
- For charts, cache daily and intraday responses by date/time bucket. You rarely need to refetch historical buckets once settled.
Weekends, holidays, and closed-market periods
If you query during a non-trading window, the Latest response can reflect the most recent available quote. In those cases, the timestamp will not advance. Your UI should keep the last valid print, show it as unchanged, and avoid implying that the price just updated.
Error handling and missing values
- Check success. If success is false, examine the error object and surface a clear message to logs and, when appropriate, the UI.
- Check for presence of rates, rates.USDXPD, and rates.XPD. If both are missing, don’t attempt to display a price; instead, retry with backoff and log the payload.
- Validate numeric types. Avoid printing NaN or infinite values due to arithmetic on nulls or zeros.
Single-source symbol and consistency
Use only the ISO symbol XPD for palladium across endpoints to maintain a consistent series. Do not co-mingle venue codes or non-ISO abbreviations. If you maintain a symbol map, lock XPD to “palladium” and USDXPD to “USD per ounce of palladium” and reuse across Latest, timeseries, and intraday.
Designing endpoints into your app
Most apps will need a mix of Latest (for the current print) and historical windows (for charts/analytics). Below is a simple routing of use cases to endpoints, which you can adapt to your architecture.
| Use case | Endpoint | Notes |
|---|---|---|
| Live price display (USD/oz) | /api/latest | Call with base=USD&symbols=XPD; render rates.USDXPD |
| Daily charts and backfills | /api/timeseries | Use a daily window; keep symbol XPD and base=USD for a consistent series |
| Hourly monitoring and alerts | /api/intraday | Hourly candles; one symbol per call (XPD) |
From sandbox to production: what to test
- Round-trip: Confirm your Latest call returns both rates.XPD and rates.USDXPD; simulate the fallback by ignoring USDXPD to verify inversion logic.
- Staleness: Cache a response and verify your UI handles an unchanged timestamp without flicker or false “updated” states.
- Numeric safety: Force edge cases (null, zero, missing fields) and ensure your app shows a sensible error state instead of NaN.
- History joins: If you render charts, join Latest to your most recent historical bucket without double counting the last bar.
Learn more and sign up
The full developer reference covers all endpoints, parameters, and payload structures: Documentation. To get a key and start calling the API, Register. Copper Monthly starts at $19.99/mo. There is no Free Trial.
FAQ
Which field should I display as “USD per ounce” for palladium?
Use rates.USDXPD. If it’s not present, compute 1 / rates.XPD (with base=USD) and display that.
What unit does XPD represent?
XPD is ISO 4217 for palladium priced per troy ounce. Convert to grams or kilograms in your code if your UI requires it.
How do I fetch hourly palladium data?
Use GET /api/intraday for hourly candles. Request one symbol per call and keep the symbol XPD consistent with your Latest usage.
How do I backfill a daily chart for palladium?
Use GET /api/timeseries to retrieve a daily window for XPD with base=USD. Store results with their timestamps and only refresh settled days when necessary.
Where can I review sources and methodology?
See the consolidated methodology and coverage on the MCP page.
Ready to read XPD as JSON and wire it into your product? Get your access key and start integrating in minutes: Register.