Get iShares Gold Trust (IAU) - Per Ounce Historical Prices using this API - daily close values
If your goal is to chart iShares Gold Trust (IAU) in terms of per-ounce gold closing prices, you can do it reliably with Metals-API. This guide shows how to fetch daily close values for gold (symbol: XAU), map them to IAU’s gold exposure, and integrate them into dashboards, quant backtests, or portfolio analytics. We’ll focus on the “per troy ounce” convention and daily closing prices, using only the endpoints you need to get clean, production-ready time series.
Why use per-ounce XAU daily closes for IAU analytics
IAU seeks to reflect the performance of the price of gold bullion. While IAU itself is an exchange-traded fund that trades during market hours with its own microstructure, the core driver of its net asset value (NAV) is the gold price per troy ounce. Metals-API delivers those gold prices (XAU) as normalized, per-ounce rates in USD by default, so you can:
- Build IAU-aligned historical datasets using gold per-ounce daily closing prices.
- Backfill analytics when exchange data is incomplete or delayed.
- Calibrate risk models to spot gold rather than proxying through ETF bid-ask spreads.
- Power dashboards and signals that compare IAU price action to underlying spot gold close.
In short, you’ll retrieve XAU daily close values and use them as the reference price for IAU-aligned research or pricing models.
What you will build in this article
- A repeatable way to fetch daily close values for XAU (gold per troy ounce) for a date range.
- Guidance on the most relevant Metals-API endpoints: Time-series (for range requests), Historical (for specific dates), and OHLC (for daily open-high-low-close, including close).
- Robust handling of weekends, holidays, timestamps, units, and caching for scalable integrations.
Main keyword focus: Get iShares Gold Trust (IAU) per-ounce historical prices (daily close) with Metals-API
We will extract daily close prices for XAU per troy ounce and use these as the underlying series for iShares Gold Trust (IAU) analysis. This approach is common for:
- Quant research comparing IAU share moves vs. spot gold per ounce.
- Portfolio analytics that use gold close as a benchmark for IAU-based holdings.
- E-commerce or B2B quoting engines that peg gold-linked pricing to end-of-day closes.
To follow along, get your free API key from the Metals-API Website. Keep the Metals-API Documentation handy, and confirm symbols anytime via the Metals-API Supported Symbols page.
How Metals-API represents gold (XAU) and units
Before hitting endpoints, establish the data semantics:
- Symbol: XAU (gold)
- Base currency: USD by default, unless you request otherwise
- Unit: Per troy ounce (the standard for bullion markets)
The API returns either USD per troy ounce or, depending on the endpoint and base, a rate you can invert to get per-ounce price. When base is USD and the rate for XAU is a small decimal (e.g., 0.000482), that means 1 USD buys 0.000482 troy ounces. Invert to get USD per ounce: price_per_ounce_usd = 1 / rate. We will demonstrate this below and show how to consistently extract “close.”
IAU vs. XAU: practical mapping
IAU’s NAV is driven by gold bullion prices. While IAU trades on an exchange with its own intraday dynamics, the daily closing NAV typically corresponds to gold’s end-of-day value. Many analytics workflows therefore anchor IAU’s historical valuation to the daily close of XAU per troy ounce. You can thereafter scale or compare IAU’s share price to spot gold using regression, ratio charts, or gold-per-share conversion if you maintain a separate mapping. For the purposes of this guide, we focus strictly on gold per-ounce closes (XAU) as the underlying reference series that informs IAU.
Endpoints to use for IAU-aligned daily closes
We will use a minimal, precise toolkit:
- Historical Rates: to fetch the rate on a specific date (useful for point lookups and validation).
- Time-series: to pull a continuous daily range of XAU rates.
- OHLC (Open/High/Low/Close): to specifically extract daily close values per date.
For other endpoints and features, refer to the Metals-API Documentation. If you need to verify ticker support or metals coverage, use the Metals-API Supported Symbols page.
Authentication and base concepts
- API key: Pass your key via the access_key query parameter.
- Base currency: USD by default. If you do not set base, assume USD. The response then reflects troy ounces per USD for XAU in the examples below, with unit metadata included.
- Timestamps: UNIX epoch seconds fields (timestamp) are UTC-based. Store and convert consistently.
- Units: “per troy ounce” is explicit in the unit field; always log/store it alongside the series to avoid confusion with grams or kilograms.
Start by obtaining your API key here: Get a free Metals-API key.
Time-series endpoint: building a daily historical close backbone
The Time-series endpoint is your workhorse to backfill ranges. It returns daily historical rates between start_date and end_date. You’ll pair this with OHLC when you specifically need the “close” field; however, for price-per-ounce series that proxy IAU’s NAV curve, most workflows either:
- Use Time-series daily rate as their end-of-day level when that rate is an end-of-day snapshot (depends on your plan and data availability), or
- Use OHLC per day and specifically take the “close” for each date.
Time-series request example (curl)
The following request fetches XAU across a date range. Replace YOUR_KEY and choose your dates.
curl -G https://metals-api.com/api/timeseries \
--data-urlencode "access_key=YOUR_KEY" \
--data-urlencode "base=USD" \
--data-urlencode "symbols=XAU" \
--data-urlencode "start_date=2026-09-10" \
--data-urlencode "end_date=2026-09-17"
Time-series example response
{
"success": true,
"timeseries": true,
"start_date": "2026-09-10",
"end_date": "2026-09-17",
"base": "USD",
"rates": {
"2026-09-10": {
"XAU": 0.000485
},
"2026-09-12": {
"XAU": 0.000483
},
"2026-09-17": {
"XAU": 0.000482
}
},
"unit": "per troy ounce"
}
How to interpret fields you will actually use
- success: Booleans you can short-circuit on for ETL pipelines.
- timeseries: Confirms this is a time-series payload.
- start_date/end_date: Echo back your requested bounds.
- base: USD. Important for interpreting rates correctly.
- rates: Map keyed by date (YYYY-MM-DD). Each date returns a rate for XAU.
- unit: “per troy ounce” ensures your downstream math remains unit-safe.
Because base is USD, the XAU rate is stated as troy ounces per USD. To obtain USD per troy ounce (a chart-friendly price), invert it:
- price_usd_per_oz = 1 / rate
Store both the raw rate and the inverted price so you can transform consistently across analytics tasks. For IAU-aligned visualizations, most users plot the inverted value: USD per troy ounce.
OHLC endpoint: extracting the daily close for XAU
When you specifically require end-of-day closes (as opposed to a generic daily rate), the OHLC endpoint returns open, high, low, and close. You can call it per date and aggregate into a time series of closes.
OHLC example response
The example below shows a single-date OHLC snapshot with a closing XAU rate. This pairs neatly with IAU use cases where you need a definitive daily close for the underlying gold price.
{
"success": true,
"timestamp": 1789654945,
"base": "USD",
"date": "2026-09-17",
"rates": {
"XAU": {
"open": 0.000485,
"high": 0.000487,
"low": 0.000481,
"close": 0.000482
}
},
"unit": "per troy ounce"
}
As with the time-series endpoint, rates are quoted relative to base=USD. That means the “close” value here is in troy ounces per USD. To compute the closing price in USD per troy ounce for that date, invert close: close_price_usd_per_oz = 1 / close_rate.
Field breakdown for OHLC
- timestamp: UNIX epoch (UTC). Synchronize it with your data warehouse time standards.
- date: The market date for the OHLC snapshot (YYYY-MM-DD).
- rates.XAU.open/high/low/close: Ounces per USD. Invert for USD per ounce.
- unit: Confirms per troy ounce basis.
Historical Rates: point lookups and validation
Historical Rates is the simplest way to retrieve a specific day’s rate for XAU. It’s useful for point checks, notebook exploration, and pipeline validation.
Historical Rates example response
{
"success": true,
"timestamp": 1789568545,
"base": "USD",
"date": "2026-09-16",
"rates": {
"XAU": 0.000485
},
"unit": "per troy ounce"
}
Again, invert the rate for USD per troy ounce. For reproducible IAU studies, prefer OHLC close when a precise “close” is needed; use Historical Rates or Time-series for fast lookups and range fills.
Putting it together: build an IAU-aligned daily close series
Here’s a straightforward workflow for daily closes that proxy IAU’s gold exposure:
- Define your calendar: Use business days in your target timezone or a metals calendar. Generally assume UTC-based timestamps from the API.
- For each date, fetch the OHLC record and take the close for XAU. Invert to get USD per troy ounce.
- Optionally cross-check a subset against Time-series or Historical Rates for QA.
- Persist the result as “XAU_close_usd_per_oz” in your data store.
- Map your IAU analyses to this close series for NAV-aligned insights.
End-to-end example query (curl) for a single date close
Assuming the OHLC endpoint is structured by date, you can request a given day, then extract the “close” for XAU. Replace YOUR_KEY and the date value.
curl -G https://metals-api.com/api/open-high-low-close/2026-09-17 \
--data-urlencode "access_key=YOUR_KEY" \
--data-urlencode "base=USD" \
--data-urlencode "symbols=XAU"
Programmatic retrieval (Python) for a date range of closes
This snippet demonstrates looping dates, calling OHLC once per date, and computing USD per troy ounce close values for downstream IAU analytics. Replace YOUR_KEY before running.
import datetime as dt
import time
import requests
API_KEY = "YOUR_KEY"
BASE_URL = "https://metals-api.com/api"
def ohlc_close_xau_per_oz_usd(date_str):
url = f"{BASE_URL}/open-high-low-close/{date_str}"
params = {
"access_key": API_KEY,
"base": "USD",
"symbols": "XAU"
}
r = requests.get(url, params=params, timeout=10)
r.raise_for_status()
data = r.json()
if not data.get("success"):
raise RuntimeError(f"API error: {data}")
close_rate = data["rates"]["XAU"]["close"] # ounces per USD
# Invert to get USD per ounce
close_price_usd_per_oz = 1.0 / close_rate
return {
"date": data["date"],
"timestamp": data["timestamp"],
"unit": data["unit"],
"close_rate_oz_per_usd": close_rate,
"close_price_usd_per_oz": close_price_usd_per_oz
}
def daterange(start, end):
cur = start
while cur <= end:
yield cur
cur += dt.timedelta(days=1)
start_date = dt.date(2026, 9, 10)
end_date = dt.date(2026, 9, 17)
results = []
for d in daterange(start_date, end_date):
# Optional: skip weekends if your downstream requires business days only
try:
res = ohlc_close_xau_per_oz_usd(d.isoformat())
results.append(res)
time.sleep(0.2) # small delay to be polite and respect quotas
except Exception as e:
# Log and continue; handle API retries/backoff as needed
print("Error on", d, ":", e)
for row in results:
print(row["date"], row["close_price_usd_per_oz"])
Sample JSON you might see in loop
Here’s a realistic OHLC payload like the one printed above, with a closing value you can invert:
{
"success": true,
"timestamp": 1789654945,
"base": "USD",
"date": "2026-09-17",
"rates": {
"XAU": {
"open": 0.000485,
"high": 0.000487,
"low": 0.000481,
"close": 0.000482
}
},
"unit": "per troy ounce"
}
Practical guidance you should not skip
Units: troy ounces vs grams
- Metals-API returns gold in “per troy ounce.” This is not the same as a standard ounce or a gram. A troy ounce is ~31.1034768 grams.
- If your downstream system quotes in grams or kilograms, convert explicitly and track unit lineage in your schema.
Understanding base and inversion
- With base=USD, XAU values are returned as ounces per USD (a small decimal). Invert to get the more familiar USD per ounce price.
- If you change the base to a different currency, confirm the directionality and continue to store the unit.
Timestamps and timezone
- timestamp fields are UNIX epoch seconds in UTC. Convert to your analytics timezone only at the presentation or reporting layer to avoid confusion.
Weekends and market closures
- Spot markets can show reduced or no updates during weekends and certain holidays. Your time series may have flat days or missing entries.
- For IAU comparisons, stick to business days if your ETF analytics reference exchange trading sessions, or retain the full calendar if your model uses a continuous daily clock.
Caching
- Cache historical responses aggressively (e.g., object storage or Redis) to save quota and accelerate backfills.
- Introduce an LRU cache on your OHLC-by-date function; historical closes do not change after finalization.
Designing a robust IAU analytics pipeline
Below is a canonical flow you can deploy into production for sustained, low-latency service:
- Scheduler triggers nightly after market close (choose a consistent UTC cutoff).
- For the target date, call OHLC for XAU and compute USD per troy ounce close; persist to a fact table.
- Periodically run Time-series backfills for newly extended ranges; de-duplicate rows on (symbol, date) keys.
- Expose the final table to dashboards, notebooks, and alerting systems that trend IAU vs. underlying XAU close.
- Instrument monitoring: success flags, non-200 HTTPs, and anomalous rate values (e.g., sudden zeros or nulls).
Detailed endpoint documentation for this workflow
1) Time-series endpoint
Purpose: Retrieve daily historical XAU rates for a date range; ideal for bulk backfills and sanity checks against your OHLC-derived close series.
- Key parameters you will use:
- access_key: your API key
- base: set to USD (or omit to use default USD)
- symbols: XAU
- start_date: inclusive, YYYY-MM-DD
- end_date: inclusive, YYYY-MM-DD
Success response example (subset):
{
"success": true,
"timeseries": true,
"start_date": "2026-09-10",
"end_date": "2026-09-17",
"base": "USD",
"rates": {
"2026-09-10": {"XAU": 0.000485},
"2026-09-12": {"XAU": 0.000483},
"2026-09-17": {"XAU": 0.000482}
},
"unit": "per troy ounce"
}
Error/edge scenarios to handle:
- success=false: log and retry with exponential backoff.
- Empty rates for certain dates (holidays/weekends): fill-forward, skip, or mark NA per your modeling choice.
- Out-of-range dates: clamp to supported history and alert if user input exceeds limits.
Performance and optimization:
- Batch by months or quarters for long histories.
- Persist each day’s record keyed by date for idempotent re-runs.
- Cache responses and avoid repeated fetches for the same date window.
Security tips:
- Keep access_key outside source control (env vars, secrets manager).
- Use HTTPS only; validate TLS in your HTTP client.
2) OHLC endpoint
Purpose: Obtain per-date open/high/low/close for XAU and extract the daily close that best aligns with IAU’s NAV-driven end-of-day profile.
- Key parameters:
- access_key: your API key
- base: USD (recommended)
- symbols: XAU
- Path or date parameter: set to target YYYY-MM-DD based on the API pattern
Success response example (single date):
{
"success": true,
"timestamp": 1789654945,
"base": "USD",
"date": "2026-09-17",
"rates": {
"XAU": {
"open": 0.000485,
"high": 0.000487,
"low": 0.000481,
"close": 0.000482
}
},
"unit": "per troy ounce"
}
Error/edge scenarios to handle:
- Non-trading days may still return values depending on how the market finalizes; otherwise, handle missing payloads by either skipping or applying your calendar rules.
- Validate unit equals “per troy ounce.” If not present, fail safe and log.
- success=false or missing symbols: perform retries within your quota policy; alert if persistent.
Performance and optimization:
- Run once per date and cache permanently—finalized closes don’t change historically.
- For large backfills, schedule rate-limited parallelization across multiple days.
Security tips:
- Rotate API keys on a regular cadence and restrict their distribution.
- Centralize outbound requests behind a secure egress with monitoring.
3) Historical Rates endpoint
Purpose: Quick retrieval of the XAU rate for a specific date. Use this for spot checks, pipeline tests, or supplementing time-series gaps.
Success response example:
{
"success": true,
"timestamp": 1789568545,
"base": "USD",
"date": "2026-09-16",
"rates": {
"XAU": 0.000485
},
"unit": "per troy ounce"
}
Error/edge scenarios to handle:
- If success=false, capture the error message and switch to a retry path or a fallback date.
- Missing XAU key: treat as a data integrity issue; escalate and halt writes for that date to avoid polluting your series.
Performance and optimization:
- Cache these one-off lookups; they’re cheap to store and fast to re-serve internally.
How to compare symbols and naming in your schema
| Concept | Symbol | Notes |
|---|---|---|
| Gold (per troy ounce) | XAU | Use “XAU_close_usd_per_oz” as a canonical column for daily close after inversion. |
| ETF (not provided by Metals-API) | IAU | Use market data source for IAU price if you need ETF trading prices. For NAV-aligned analyses, use XAU daily close from Metals-API. |
Validation techniques for high-integrity datasets
- Unit tests that confirm “unit == per troy ounce” across all inserts.
- Spot-check daily closes by inverting and verifying monotonicity within ± expected ranges.
- Cross-compare the Time-series daily rate and the OHLC close for random samples to detect anomalies early.
- Backtest alignment: correlate IAU returns vs. XAU_close_usd_per_oz returns to validate consistency.
Resilience: errors, retries, and data quality
- Retry policy: exponential backoff on network timeouts and server errors; cap retries to protect quotas.
- Circuit breaker: if daily fetches fail consecutively, pause jobs and alert ops.
- Idempotency: Upsert by (symbol=XAU, date), never duplicate rows.
- Data quarantine: if a day’s response is malformed, isolate that date’s batch and continue for others.
Scaling: performance and quotas
- Cache-first: Store all historical payloads to avoid re-querying.
- Batch windows: Fetch months at a time via Time-series for initial backfills, then daily OHLC for maintenance.
- Concurrency: Respect API quotas; control concurrency with a worker pool and rate-aware queue.
Security considerations
- Secrets hygiene: Keep access_key in environment variables or a secrets manager; never hard-code.
- Least privilege: Limit access to the secrets in CI/CD and runtime containers.
- Auditing: Log every outbound request (timestamp, path, date, symbol), but mask keys in logs.
Advanced analysis ideas for IAU using XAU closes
- Tracking error: Compute rolling correlations between IAU returns and XAU close returns.
- NAV premium/discount proxy: Compare IAU close-to-close moves to underlying XAU close moves.
- Signal overlays: Combine XAU close with technical indicators for allocation signals into IAU.
- Hedging: Use XAU close as the mark for gold exposure in risk systems that hold IAU.
Additional resources and where to go next
- Review the complete API feature set in the Metals-API Documentation.
- Confirm symbols and units on the Metals-API Supported Symbols page.
- Sign up for a key and start testing in minutes on the Metals-API Website.
For ETF price series like IAU itself, you’ll typically pull those from your market data provider and then align to Metals-API’s XAU daily close for clean underlying comparisons.
Conclusion
To model iShares Gold Trust (IAU) through the lens of its underlying bullion exposure, you need accurate per-ounce gold daily closes. Metals-API gives you exactly that via XAU in “per troy ounce” units, returned relative to USD by default. Use the Time-series endpoint for range backfills, the Historical endpoint for point lookups, and the OHLC endpoint when you want a definitive “close” for each date. Handle units carefully, invert the returned rate to get USD per troy ounce, and apply robust caching, retries, and data QA for production reliability. With this foundation, you can run precise NAV-aligned analytics, build dashboards, and power allocation signals that reflect the core driver of IAU—gold per troy ounce.
Get started now: visit the Metals-API Website, grab your key, scan the Metals-API Documentation, and confirm XAU on the Metals-API Supported Symbols page.
FAQ
Is IAU itself directly available as a symbol from Metals-API?
No. Metals-API focuses on metals and currency rates. For IAU’s ETF trading prices, use your market data provider. For the underlying bullion series that informs IAU, use XAU daily closes from Metals-API.
Which endpoint should I use for daily close values?
Use the OHLC endpoint and extract the “close” for XAU, then invert to get USD per troy ounce. For backfills or quick checks, combine with Time-series and Historical endpoints.
Why are XAU values small decimals?
Because base=USD returns ounces per USD. Invert to get the familiar USD per ounce.
What timezone are timestamps in?
UNIX epoch seconds in UTC. Convert for display, but store in UTC to maintain consistency.
How do I handle weekends and holidays?
Decide up front: either keep a continuous daily calendar (and accept unchanged values on closures) or restrict to business days if aligning with ETF trading sessions.
Can I convert to grams?
Yes. Convert from troy ounces to grams (1 troy ounce ≈ 31.1034768 grams) after you compute USD per troy ounce.
How should I optimize for performance and quotas?
Cache historical responses, batch time-series queries for backfills, and run the OHLC daily job once after close with retries and alerts.
Where do I find a list of supported symbols?
Use the Metals-API Supported Symbols page.
Where can I read detailed API docs?
See the Metals-API Documentation.