Get Gold UAE 18 k (XAUUAE18) - Per Gram Historical Prices using this API: curl requests for quick testing
You need historical, per-gram pricing for Gold UAE 18k (symbol: XAUUAE18) to backfill charts, validate ERP purchase orders, and run strategy and inventory backtests. In this guide you’ll query Metals-API for a single historical date and for a date range, get back real JSON, and turn it into date/value pairs you can chart or store.
What you’ll build: reliable XAUUAE18 per-gram history for backtests, charts, and reconciliation
We’ll use two endpoints that cover most workflows:
- Historical by date: fetch the XAUUAE18 price for a specific day, ideal for order reconciliation and point-in-time P&L.
- Time-series: pull a continuous daily series for charting, backtesting, and analytics.
If you’re new to this symbol, confirm it on the official list before you code: browse supported symbols. You’ll need an API key—grab one in minutes: Register. For endpoint details and parameters, keep the Documentation open.
Single-date historical price for XAUUAE18 (per gram)
Use the historical endpoint by appending the date (YYYY-MM-DD) to the base URL and passing your access_key and the XAUUAE18 symbol. The API’s base currency defaults to USD. The response structure lets you read both the asset-per-USD rate and its USD cross.
curl you can paste and run
curl "https://metals-api.com/api/2026-10-10?access_key=YOUR_API_KEY&symbols=XAUUAE18,USD,USDXAUUAE18"
Official example response (keep these values for testing and for parsing logic):
{"success":true,"timestamp":1791591300,"date":"2026-10-10","base":"USD","rates":{"XAUUAE18":0.0096240248461331,"USD":1,"USDXAUUAE18":103.90663116396635}}
What these fields mean for your code
- success: Boolean status of the call.
- timestamp: Unix epoch seconds for the snapshot (assume UTC).
- date: The effective historical date of the rates payload.
- base: Base currency for rates. By default it’s USD.
- rates.XAUUAE18: Asset-per-USD. For per-gram symbols, this is grams per 1 USD.
- rates.USD: Always 1 when base=USD.
- rates.USDXAUUAE18: The cross-rate of USD per gram for XAUUAE18, i.e., the per-gram price in USD.
Most downstream apps want “USD per gram.” Use rates.USDXAUUAE18 directly. If you only have XAUUAE18 and need USD per gram, invert it: 1 / XAUUAE18. For completeness, 1 troy ounce = 31.1034768 grams, so if you need per-ounce for comparison, multiply the USD-per-gram value by 31.1034768.
Build a daily time series for XAUUAE18
To chart or backtest, query a range with the time-series endpoint. You’ll receive a map of dates to rate objects. Request only the fields you need to reduce payload size and speed parsing.
curl time-series request
curl "https://metals-api.com/api/timeseries?access_key=YOUR_API_KEY&start_date=2026-10-01&end_date=2026-10-10&symbols=XAUUAE18,USDXAUUAE18"
The response dates will key objects similar to the single-date payload, containing XAUUAE18 and USDXAUUAE18 for each day within the allowed range.
Python: transform to a list of date/value pairs (USD per gram)
import os
import requests
API_KEY = os.getenv("METALS_API_KEY", "YOUR_API_KEY")
url = "https://metals-api.com/api/timeseries"
params = {
"access_key": API_KEY,
"start_date": "2026-10-01",
"end_date": "2026-10-10",
"symbols": "XAUUAE18,USDXAUUAE18",
}
r = requests.get(url, params=params, timeout=15)
r.raise_for_status()
data = r.json()
if not data.get("success"):
raise RuntimeError(f"API error: {data}")
# Build [(date, usd_per_gram)] sorted by date
series = []
rates_by_date = data.get("rates", {})
for dt, payload in sorted(rates_by_date.items()):
# Prefer direct USD per gram if provided
usd_per_gram = payload.get("USDXAUUAE18")
if usd_per_gram is None:
# Fallback: invert grams per USD
xauuae18 = payload.get("XAUUAE18")
usd_per_gram = (1.0 / xauuae18) if xauuae18 else None
if usd_per_gram is not None:
series.append((dt, usd_per_gram))
print(series[:3], "...", series[-3:])
This snippet prefers USDXAUUAE18 (already USD/gram). If missing, it computes 1 / XAUUAE18 safely. The sorted list of tuples is friendly for plotting, CSV export, or DataFrame creation. If you need per ounce, multiply each USD-per-gram value by 31.1034768.
Understanding units, base currency, and time
Units:
- XAUUAE18 refers to 18-karat gold priced per gram. Use USDXAUUAE18 to get USD per gram directly.
- If you start with XAU (troy-ounce gold) in other workflows, remember 1 troy ounce = 31.1034768 grams. Do not mix ounce- and gram-based symbols without converting.
Base currency:
- By default, base=USD. Rates like XAUUAE18 represent “asset per USD,” while USDXAUUAE18 is “USD per asset.”
- If you change base, re-check the semantics (rates become asset per base unit). For this workflow, stick to base=USD and read USDXAUUAE18.
Timestamp and timezone:
- Use the timestamp (epoch seconds) for exact versioning and cache keys. Timestamps are UTC-aligned.
- The date field is the effective calendar date for the historical snapshot, also in UTC.
Practical implementation details that save time
- Weekend and holiday behavior: Metals trade 24/5. Historical snapshots typically reflect the last available trading day when markets are closed. If your request lands on a weekend/holiday, the date field in the response indicates the effective snapshot; your time-series may show repeated values across non-trading days.
- Maximum range per request: Time-series limits depend on plan. When you need long spans, batch requests by month or quarter and stitch them together. Refer to the Documentation for current limits and pagination rules (where applicable).
- Caching and backfills: Cache by (endpoint, symbol set, start_date, end_date, base) and validate freshness using timestamp. For daily backfills, store the final UTC snapshot for each date to avoid accidental intra-day overwrites.
- Stability across replays: Use the exact symbols you chart (XAUUAE18 and USDXAUUAE18) to avoid unit surprises. Document your unit conventions in code comments.
- Downstream currency needs: If your UI needs local currency (e.g., AED), request the appropriate USD cross in the same call when available, or convert later using the Convert endpoint (see docs) while keeping your canonical store in USD per gram.
Applying digital gold data in modern stacks
Gold is no longer only a physical market input—its price stream powers digital workflows: automated catalog repricing in jewelry e-commerce, ERP cost-of-goods audits, and quant backtests in commodities strategies. With per-gram, 18k granularity (XAUUAE18), Metals-API helps you align your data shape with how inventory is actually measured and sold.
- Data analytics: Persist USDXAUUAE18 daily values, run moving-average bands and intraday-to-daily rollups, and track discounts/premiums vs. pure XAU ounce benchmarks after converting units.
- Technology integration: Design your services around immutable daily snapshots (timestamp + date) and expose a thin “USD per gram” accessor to downstream apps.
- Innovation in price discovery: Use the time-series endpoint to compute realized volatility or day-over-day deltas for alerting and customer-facing dashboards.
Keep the reference materials at hand: the full endpoint documentation, the symbol catalogue, and the MCP overview for methodology context.
Quality checks and common pitfalls for XAUUAE18
- Verify symbol intent: XAUUAE18 is 18-karat, per-gram. Do not substitute with ounce-based XAU or other carats. If unsure, reconfirm on Supported Symbols.
- Use the right side of the quote: When you need a display price per gram, use USDXAUUAE18 (USD per gram). Avoid accidentally charting XAUUAE18 (grams per USD) unless that’s intentional for FX-style analytics.
- Normalize decimals: Store numbers as decimal or high-precision float in your database. Multiply by 1000 if you need mg-level precision and work in integers.
- UTC handling: Align daily jobs to a consistent UTC boundary to avoid split-day caches.
- Reconciliation: For ERP backfills, store date, timestamp, and both XAUUAE18 and USDXAUUAE18 to enable recomputations without refetching.
curl quick tests you’ll actually reuse
Single-date (already shown above) and a second quick probe to validate a new day before you schedule a full backfill:
# Check today's effective historical snapshot (example date shown)
curl "https://metals-api.com/api/2026-10-10?access_key=YOUR_API_KEY&symbols=XAUUAE18,USDXAUUAE18"
# Fetch a 7-day window for spot-checking a chart
curl "https://metals-api.com/api/timeseries?access_key=YOUR_API_KEY&start_date=2026-10-04&end_date=2026-10-10&symbols=XAUUAE18,USDXAUUAE18"
Interpreting and storing the official example payload
Here’s the same official payload again for clarity:
{"success":true,"timestamp":1791591300,"date":"2026-10-10","base":"USD","rates":{"XAUUAE18":0.0096240248461331,"USD":1,"USDXAUUAE18":103.90663116396635}}
- Store date and timestamp as your natural keys. They guarantee deterministic replays.
- Persist both rates.XAUUAE18 and rates.USDXAUUAE18. Your display code should use USDXAUUAE18 for “USD per gram.”
- If you need price in another currency later, derive it via a conversion step rather than re-pulling the same day repeatedly.
Where to dig deeper
- API overview and endpoint parameters: Metals-API Documentation
- Home and product overview: Metals-API website
- Methodology context: MCP
- Symbol reference (confirm XAUUAE18): Metals-API Supported Symbols
- Background reading on market structure and benchmarks: LBMA prices and data
- Another high-level overview: Metals-API homepage
FAQ
What unit does XAUUAE18 use?
XAUUAE18 is a per-gram symbol for 18k gold. For a display price in USD per gram, read rates.USDXAUUAE18. If you only have rates.XAUUAE18 (grams per USD), invert it.
Why do I sometimes see repeated values across days?
On weekends and certain holidays, the historical series can repeat the last available trading snapshot. Use the date field and timestamp to verify the effective day.
How far back can I query with time-series?
Historical coverage and max range per request depend on plan. Batch your requests (e.g., monthly windows) and consult the Documentation for current limits.
Do I need to set base=USD?
No—USD is the default. Keep it unless you fully understand how base affects the meaning of rates and your downstream calculations.
How should I cache?
Cache by (path, date range, symbols, base). Use the timestamp as a version. For daily jobs, write-once per UTC day to avoid overwriting a final snapshot with an earlier intra-day value.
Ready to ship your XAUUAE18 integration? Get a key and start testing in minutes: Register. Then keep the Documentation handy while you wire up your historical and time-series calls.