Get Gold Feb 2028 (GCG28) - Per Troy Ounce prices using this API for real-time polling
If you’re trading or building tools around the Gold Feb 2028 futures contract (GCG28), you need a fast, reliable way to poll per–troy ounce gold prices in real time to drive quotes, risk, margin, or hedging logic. Metals-API delivers gold spot (XAU) data via a simple JSON REST API that you can poll on a schedule and transform into the inputs your GCG28 workflow needs—like USD per troy ounce fair value, intraday OHLC, and bid/ask spreads. In this guide, we show how to query XAU spot as a robust proxy data source for GCG28 monitoring and analytics, how to convert it into the units and direction you need, and how to handle practical implementation details like timestamps, base currency, caching, and weekend behavior.
Why poll gold spot (XAU) for a GCG28 workflow?
Exchanges quote GCG28 (COMEX Gold February 2028) directly, but many developer and quant stacks rely on a high-availability reference feed of per–troy ounce gold spot for:
- Real-time fair value inputs: spot XAU as the baseline for futures fair value models (carry, rates, storage, basis adjustments).
- Rapid alerting and threshold logic: spot moves trigger downstream hedges or notifications while futures markets are thin or crossed.
- Pricing and RFQ support in fintech and e-commerce: convert spot to USD/oz and price products that rely on a GCG28 hedge.
- Research and backtesting: daily time-series and OHLC for model calibration when futures history is fragmented.
Metals-API provides XAU (gold) “per troy ounce” rates updated up to multiple times per hour depending on plan. That makes it ideal for polling into broker algos, ERP systems, dashboards, and alerting. Confirm supported commodity symbols on the Metals-API Supported Symbols page. Note: futures tickers like GCG28 are not queried as symbols in this API; instead, use XAU spot and your own futures-specific adjustments. For full parameter and endpoint details, see the Metals-API Documentation.
Core concept: XAU is quoted “per troy ounce” with base USD by default
By default, Metals-API responses use base USD and report metal rates “per troy ounce.” For gold (XAU):
- Response value for XAU equals “troy ounces per 1 USD.”
- To convert to “USD per troy ounce” (what most traders want), compute 1 / XAU_rate.
Example: If rates.XAU = 0.000482 (oz per USD), then USD per oz = 1 / 0.000482 ≈ 2074.27 USD/oz. This conversion is essential when aligning spot with a GCG28 view or publishing prices to users who expect USD/oz.
What we’ll build: Real-time polling for GCG28 workflows using XAU spot
We’ll focus on three endpoints that are most useful for a GCG28-aligned toolchain:
- Latest Rates (XAU) for near-real-time spot.
- Bid/Ask for spreads and microstructure-aware logic.
- OHLC (Open/High/Low/Close) for intraday bars and charting.
We’ll show one curl request and one JavaScript example, walk through realistic JSON responses, and explain exactly which fields matter for developers mapping to GCG28 logic. For more advanced endpoints like historical and time-series data, review the Metals-API Documentation.
Prerequisites: get your API key
Sign up at the Metals-API Website and create a free API key to start testing. You’ll pass it via the access_key query parameter on each call. Plans vary by update frequency and feature access; check the docs for specifics and production SLAs. Ready to try it? Get your free API key now.
Endpoint 1: Latest XAU rate for real-time spot polling
Purpose
Retrieve the most recent XAU rate relative to USD, with values expressed per troy ounce. This is your base input for USD/oz calculations and GCG28-aligned analytics.
Sample curl request
curl "https://metals-api.com/api/latest?access_key=YOUR_API_KEY&base=USD&symbols=XAU"
Realistic JSON response
{
"success": true,
"timestamp": 1790208577,
"base": "USD",
"date": "2026-09-24",
"rates": {
"XAU": 0.000482
},
"unit": "per troy ounce"
}
Fields you’ll actually use
- success: Boolean. Check first; if false, log and retry/backoff.
- timestamp: Unix epoch seconds. Use it to align with your futures market session for GCG28 analytics, and for idempotent caching.
- base: "USD" by default. If you change base, redo the unit math accordingly.
- date: Calendar date in UTC. Helpful for day-boundary logic and EOD aggregation.
- rates.XAU: Ounces per USD. Convert to USD/oz as 1 / rates.XAU when publishing to front-ends or models expecting USD/oz.
- unit: Always “per troy ounce” for metals. Remember: 1 troy ounce = 31.1034768 grams.
JavaScript example: poll, convert to USD/oz, and round
async function fetchUsdPerOunce() {
const url = "https://metals-api.com/api/latest?access_key=YOUR_API_KEY&base=USD&symbols=XAU";
const res = await fetch(url, { cache: "no-store" });
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = await res.json();
if (!data.success || !data.rates || typeof data.rates.XAU !== "number") {
throw new Error("Invalid response");
}
const ouncesPerUsd = data.rates.XAU; // e.g., 0.000482
const usdPerOunce = 1 / ouncesPerUsd; // invert to get USD/oz
const price = Math.round(usdPerOunce * 100) / 100; // 2dp for display, keep raw for calc
return {
timestamp: data.timestamp, // seconds since epoch (UTC)
isoDate: data.date,
usdPerOunceRaw: usdPerOunce,
usdPerOunceDisplay: price,
unit: data.unit
};
}
Implementation tips for GCG28 alignment
- UTC handling: Metals-API timestamps are in UTC. If your futures logic keys off COMEX session times, convert timestamps to exchange-local time for session bucketing.
- Weekend/holidays: Expect flat or missing changes during closures. Cache the last good tick and surface a “market closed” banner in the UI.
- Caching: With plan-dependent update intervals, respect the timestamp to avoid wasting requests. Cache until a new timestamp arrives.
- Conversion discipline: Always store the raw ounces-per-USD (from the API) and your inverted USD/oz side-by-side to avoid compounding rounding errors.
Endpoint 2: Bid/Ask for microstructure-aware logic
Purpose
Retrieve bid/ask values for XAU. GCG28-aligned strategies often look at spot spreads to gate order placement, adjust slippage assumptions, or trigger alerts when spreads widen.
Sample JSON response
{
"success": true,
"timestamp": 1790208577,
"base": "USD",
"date": "2026-09-24",
"rates": {
"XAU": {
"bid": 0.000481,
"ask": 0.000483,
"spread": 2.0e-6
}
},
"unit": "per troy ounce"
}
How to use it
- Invert both bid and ask to get USD/oz sides:
- bid_usd_per_oz = 1 / ask_oz_per_usd (conservative if you think like a taker)
- ask_usd_per_oz = 1 / bid_oz_per_usd
- Compute mid in USD/oz for display or RFQ pricing:
- mid_usd_per_oz = (bid_usd_per_oz + ask_usd_per_oz) / 2
- Feed spread thresholds into a risk module that toggles your GCG28 quoting aggressiveness.
Pitfalls and checks
- Spread direction: Values are ounces-per-USD. Invert correctly per side to avoid flipping bid/ask.
- Stale checks: If timestamp didn’t update, you’re likely still within your plan’s update window. Avoid hammering the endpoint.
- Fallback: If bid/ask are absent due to plan limits, degrade gracefully to latest mid (from the Latest endpoint) and use a default spread assumption for your hedge logic.
Endpoint 3: OHLC for intraday bars, alerts, and backfills
Purpose
Get open, high, low, close values for XAU over a given date, useful for:
- Intraday or day-level bar charts in trading UIs.
- Volatility and breakout detectors powering GCG28 order placement.
- Backfills when a live feed misses a poll window.
Realistic JSON response
{
"success": true,
"timestamp": 1790208577,
"base": "USD",
"date": "2026-09-24",
"rates": {
"XAU": {
"open": 0.000485,
"high": 0.000487,
"low": 0.000481,
"close": 0.000482
}
},
"unit": "per troy ounce"
}
How to use it
- Invert each field to compute USD/oz OHLC. Use close for EOD snapshotting into your GCG28 fair-value archive.
- Synchronize the date field with your session boundaries; OHLC values are referenced to the UTC date unless specified otherwise in your plan.
- For charting, pre-compute USD/oz values server-side and cache keyed by date to accelerate front-end loads.
Units, conversions, and consistency
- Unit: “per troy ounce.” Always invert to present USD/oz to users or models.
- Grams: 1 troy ounce = 31.1034768 grams. To get USD/gram, compute USD/oz and divide by 31.1034768.
- Kilos: 1 kg = 32.1507466 troy ounces. USD/kg = USD/oz × 32.1507466.
- Carats: If you price jewelry by carat, explore the API’s carat features in the docs; for GCG28 hedges you usually stay in troy ounces.
Timestamps, time zones, and session logic
- API timestamps are Unix epoch seconds (UTC). Store and display consistently to eliminate off-by-one-day errors.
- Trading sessions: Map UTC to the exchange-local time for GCG28 if you compute session PnL, Greeks, or carry at daily cutoffs.
- Daylight savings: Use a time zone database library and never hardcode offsets.
Resilience and performance for real-time polling
- Backoff on errors: If success is false or HTTP >= 500, exponential backoff to avoid thundering herds.
- Edge caching: Cache last-known-good result until timestamp changes. This reduces request volume and smooths UI updates.
- Idempotency: Use timestamp plus symbol as a natural cache key so concurrent workers don’t duplicate work.
- Weekend/holidays: Expect flat lines; keep a “market status” indicator in your UI fed by exchange calendars.
Security and key management
- Never embed your access key directly in client-side code for public apps. Proxy requests via your backend.
- Rotate keys regularly and store them in a secure vault. Grant least privilege in your deployment pipeline.
- Input validation: Sanitize query parameters and endpoints in your proxy to prevent SSRF or header injection.
Putting it together: A GCG28-aware polling loop
At a high level, your cycle looks like this:
- Poll Latest XAU every N seconds/minutes as permitted by plan.
- Convert to USD/oz and compute a synthetic fair value for GCG28 using your model (carry, interest rates, storage, basis curves).
- Optionally poll Bid/Ask to adapt your slippage and routing logic if spreads are wide.
- For charts and analytics, fetch OHLC once per bar and store USD/oz values keyed by UTC date/session.
- Publish updates to clients or traders, and log both raw (oz/USD) and inverted (USD/oz) values for auditing.
Example: Latest XAU to USD/oz with a realistic response
{
"success": true,
"timestamp": 1790208577,
"base": "USD",
"date": "2026-09-24",
"rates": {
"XAU": 0.000482
},
"unit": "per troy ounce"
}
Key transforms:
- oz_per_usd = 0.000482
- usd_per_oz = 1 / 0.000482
- Persist both values to simplify downstream comparisons and reduce repeated inversions.
Handling errors and edge cases
- Empty rates: Treat as transient; retry with jitter. If persistent, degrade the UI with the last cached value and a timestamp badge.
- Invalid base: The response will fail; always log outgoing queries and validate base and symbols against the supported symbols list in CI.
- Stale timestamp: If you see the same timestamp frequently, it likely reflects plan update cadence; don’t spam the API.
Aligning spot (XAU) with futures (GCG28)
Because GCG28 is a futures contract and Metals-API provides spot XAU, you bridge the two with:
- Interest rates: Apply carry cost (or convenience yield if modeled) from now until Feb 2028.
- Storage and insurance assumptions: Minor, but relevant in some models.
- Basis: Historical or real-time basis between spot and the front-month future, then extend to Feb 2028 via curve modeling.
- Calendar roll logic: Keep your hedge and analytics coherent across rolls; backtesting should simulate rolling and resultant basis changes.
The API handles the spot leg with reliable, consistent pricing. Your app layers on the futures math specific to GCG28.
Production-readiness checklist
- Have a fallback data path: last-good-cache and a secondary data source if required by your SLA.
- Monitor response time, success ratio, and drift between metals spot and your GCG28 fair value.
- Alert on spreads (Bid/Ask) widening beyond thresholds you define.
- Normalize timestamps in UTC and convert at display time only.
Links, documentation, and symbol discovery
- API quick start and details: Metals-API Documentation
- Check which symbols are available: Metals-API Supported Symbols
- Create your key and start testing: Metals-API Website
- For futures contract specs and calendars, consult your exchange (e.g., CME Group Gold futures page) to align sessions and expiries.
Extended JSON examples for testing
Latest endpoint (multi-metal shown, you would filter to XAU)
{
"success": true,
"timestamp": 1790208577,
"base": "USD",
"date": "2026-09-24",
"rates": {
"XAU": 0.000482
},
"unit": "per troy ounce"
}
Time-series (useful for daily backfills and model calibration)
{
"success": true,
"timeseries": true,
"start_date": "2026-09-17",
"end_date": "2026-09-24",
"base": "USD",
"rates": {
"2026-09-17": { "XAU": 0.000485 },
"2026-09-19": { "XAU": 0.000483 },
"2026-09-24": { "XAU": 0.000482 }
},
"unit": "per troy ounce"
}
Tip: Invert each day’s XAU to get USD/oz, store that in your warehouse with date keys and UTC timestamps. If you need a rolling 20-day vol for GCG28 models, compute it on the USD/oz series.
Fluctuation (for quick period-over-period change)
{
"success": true,
"fluctuation": true,
"start_date": "2026-09-17",
"end_date": "2026-09-24",
"base": "USD",
"rates": {
"XAU": {
"start_rate": 0.000485,
"end_rate": 0.000482,
"change": -3.0e-6,
"change_pct": -0.62
}
},
"unit": "per troy ounce"
}
Usage: change_pct is on the ounces-per-USD scale. If you convert to USD/oz, recompute percentage change accordingly to avoid tiny asymmetry from inversion.
Data governance and traceability
- Record raw payloads for audit: Keep the API JSON with timestamp and request URL hash to reproduce downstream values later.
- Dual storage of scales: Persist both oz/USD and USD/oz in your fact tables; tag with unit metadata.
- Version your transforms: If your USD/oz rounding or calendar alignment logic changes, bump a transform version so historical queries remain consistent.
Observability
- Metrics: time-to-first-price, successful polls per interval, price update interval vs. plan cadence.
- Logs: request IDs, timestamps, and deltas between consecutive prices.
- Alerts: stale data thresholds based on timestamp age; spread widening alerts using Bid/Ask.
Digital transformation in precious metals: why APIs matter for GCG28
Gold trading is shifting rapidly toward software-mediated price discovery and automation. With Metals-API feeding real-time XAU spot into your stack, you can:
- Build adaptive quoting engines that respond to microstructure (via Bid/Ask) and macro volatility in seconds.
- Automate hedging: Recompute GCG28 fair value continuously and route orders when basis is attractive.
- Expand analytics: Generate intraday OHLC bars and compute signals without maintaining complex data infrastructure.
These capabilities sit at the intersection of data analytics, market microstructure, and technology integration—exactly where innovative price discovery and digital asset solutions are accelerating.
Common implementation patterns
- Polling service: A stateless worker polls, converts to USD/oz, and publishes to Redis/pub-sub for downstream consumers (UIs, risk engines).
- Warehousing: Store daily USD/oz closes (and raw oz/USD) for backtesting and model calibration.
- API gateway: Wrap Metals-API with your own microservice that normalizes output shapes and provides circuit breakers.
Compliance and controls
- Access policy: Restrict outbound calls to Metals-API hosts, allowlisted only.
- PII: None needed for metals polling; keep your service minimal to reduce security footprint.
- Disaster recovery: Backup caches and snapshots of key price levels, especially EOD values used in PnL.
Checklist before going live
- Confirm XAU is on your plan in the symbols list.
- Establish cache TTL strategy tied to timestamp changes.
- Implement proper unit conversion and validation tests.
- Design retries with exponential backoff and jitter.
- Instrument alerts for stale feed and spread anomalies.
Conclusion
To support a Gold Feb 2028 (GCG28) strategy or product, you don’t need to query a futures ticker directly from a pricing API. With Metals-API, you can poll XAU spot “per troy ounce,” transform it into USD per oz, and feed fair value models, dashboards, and risk tooling in real time. Add Bid/Ask for microstructure-aware logic and OHLC for intraday analytics, and you’ve covered the core inputs most GCG28 workflows need—backed by a straightforward JSON REST interface and practical caching strategies.
Start building today: browse the Metals-API Documentation, confirm coverage on the Supported Symbols page, and get your free key from the Metals-API Website.
FAQ
Does Metals-API support the GCG28 symbol directly?
No. Metals-API provides symbols like XAU (gold spot) per troy ounce. For GCG28-specific modeling, use XAU spot as your base input and apply futures carry, basis, and curve logic.
What unit does XAU come in?
Responses are quoted “per troy ounce” relative to the base currency (USD by default), giving ounces per 1 USD. Invert to get USD per ounce.
How often are prices updated?
Update frequency depends on your plan. The response timestamp tells you when the quote last changed. Cache until the timestamp updates to avoid wasted calls.
How should I handle weekends and holidays?
Expect flat data during closures. Keep and display the last-known-good price, plus a “market status” or “as of” timestamp.
Can I get bid/ask and OHLC?
Yes, depending on plan. Use Bid/Ask for spreads and OHLC for bars. See the documentation for access details.
How do I convert to grams or kilograms?
USD/gram = USD/oz ÷ 31.1034768; USD/kg = USD/oz × 32.1507466. Maintain precision by doing conversions server-side with high-precision arithmetic.
What about rate limits and quotas?
Follow your plan’s limits, cache aggressively using the timestamp, and implement exponential backoff on errors. Details are in the Metals-API Documentation.