The Easiest Way to Get Gold Feb 2027 (GCG27) - Per Troy Ounce Historical Rates — via REST API endpoints
If your team needs historical prices for the Gold February 2027 futures contract (ticker: GCG27) to power backtesting, price dashboards, valuation models, or risk reports, the simplest path is to call a small handful of Metals-API REST endpoints and store the results in your analytics stack. This guide shows exactly how to request and interpret GCG27 historical rates “per troy ounce,” get daily time-series windows, and retrieve open/high/low/close snapshots, with practical tips on symbols, units, timestamps, caching, and weekend/holiday handling. You’ll see concrete curl and JavaScript examples, realistic JSON responses, and implementation strategies you can use today.
Why query GCG27 historical data via API?
The GCG27 contract (COMEX Gold, February 2027) is a key input for systematic traders, treasury and hedging desks, jewelry and manufacturing pricing models, and fintech tools providing market intelligence. Gold is quoted by troy ounce, and developers often need precise, reproducible daily snapshots to:
- Backfill charts and factor models for pre-trade analysis
- Calibrate pricing engines and mark-to-market valuations
- Compute realized volatility, skew, or carry vs. nearby contracts
- Benchmark alerts and thresholds for automated workflows
- Drive ERP or e-commerce pricing updates tied to a specific delivery month
Metals-API returns GCG27 rates in a normalized, developer-friendly JSON schema, with a default base currency of USD and a consistent unit (“per troy ounce”). You can integrate results into Python notebooks, JavaScript front-ends, data warehouses, or stream-processing backends with minimal glue code. To get started or review full parameter options, see the Metals-API Documentation. If you need to confirm symbol coverage (including GCG27), check the authoritative Metals-API Supported Symbols. When you’re ready, visit the Metals-API Website and get a free API key.
Main concept: rates are per troy ounce, base is USD
By default, Metals-API returns rates relative to a base currency (USD unless you override it). For metals, each rate expresses “how many troy ounces per 1 USD.” For example, a response of "GCG27": 0.000482 means 1 USD buys 0.000482 troy ounces of the GCG27 contract’s underlying price reference. To get the more familiar “USD per troy ounce,” invert the value: usd_per_oz = 1 / 0.000482. Always store both to avoid repeated inversion in analytics loops.
Endpoints to use for GCG27 historical work
To keep integration fast and robust, focus on these two or three endpoints only:
- Historical Rates (single day) — for daily snapshots at an exact date
- Time-series — for continuous daily history between two dates
- OHLC — for open/high/low/close on a given date
We will not enumerate every available endpoint here; instead, we’ll link out to the full reference when helpful. See all details in the endpoint documentation.
Confirm symbol coverage and contract conventions
Before sending requests, confirm GCG27 is available on your plan in the Supported Symbols list. Pay attention to:
- Exact symbol spelling (GCG27)
- Unit: “per troy ounce”
- Base currency defaults (USD)
- Any plan-specific access for futures symbols
For contract background (delivery month, exchange, typical contract size), review the gold futures product specs from the exchange as needed. Example references:
- CME Group Gold Futures Contract Specs (overview of the GC contract, commonly 100 troy ounces per contract)
- Investopedia: Troy Ounce Explained (units and conversions)
Authentication basics
You authenticate by passing your API key via the access_key query parameter. If you don’t have a key, create one at the Metals-API Website now. Keep keys in environment variables or secret managers; never hardcode in public repos.
Endpoint 1: Historical Rates (single day) for GCG27
Purpose: Retrieve the GCG27 rate for a specific historical date. This is the building block for backfills, daily closes, and point-in-time audit trails.
Request format
Call the dated path format and include GCG27 in the symbols filter to scope results:
- Method: GET
- Path:
/api/YYYY-MM-DD - Query parameters:
access_key— your API keysymbols—GCG27base— optional; defaults toUSD
Example curl: Get GCG27 on 2026-09-20
curl "https://metals-api.com/api/2026-09-20?access_key=YOUR_API_KEY&symbols=GCG27&base=USD"
Representative JSON response
{
"success": true,
"timestamp": 1789863523,
"base": "USD",
"date": "2026-09-20",
"rates": {
"GCG27": 0.000485
},
"unit": "per troy ounce"
}
Key fields and how to use them
success: Boolean indicating request status. Check before parsing.timestamp: Unix epoch (seconds). Use for time alignment and caching. Treat as UTC.date: The historical date snapshot you requested (YYYY-MM-DD). Immutable for that endpoint.base: The base currency for all rates in the payload (default USD).rates.GCG27: Ounces per 1 base unit (here, troy ounces per 1 USD). Invert for USD/oz.unit: “per troy ounce,” confirming the metal unit convention.
Common implementation patterns
- Store both
rates.GCG27and1 / rates.GCG27as separate columns (oz_per_usd, usd_per_oz) for fast downstream queries. - Key your historical-price cache by
(symbol, date, base)to avoid duplicate API hits for immutable days. - For weekends/holidays when markets are closed, expect unchanged or carried-forward values depending on your plan’s data granularity. Handle missing dates explicitly by iterating calendar days and filling from the last available business day if your model allows.
Error and edge cases
- Invalid symbol: Return payload will include
success: falsewith an error object. Confirm GCG27 exists in Supported Symbols and in your plan. - Out-of-range date: Historical coverage typically begins in 2019 for most assets. Use dates within supported bounds.
- Base currency mismatch: If you override
base, update your math and display units accordingly.
Endpoint 2: Time-series (multi-day) for GCG27
Purpose: Pull continuous daily history for GCG27 between two dates in a single request. Ideal for backfilling a chart, initializing a time series database, or running multi-day computations like rolling returns.
Request format
- Method: GET
- Path:
/api/timeseries - Query parameters:
access_key— your API keysymbols—GCG27start_date— YYYY-MM-DDend_date— YYYY-MM-DDbase— optional; defaults toUSD
Example curl: GCG27 from 2026-09-14 to 2026-09-21
curl "https://metals-api.com/api/timeseries?access_key=YOUR_API_KEY&symbols=GCG27&base=USD&start_date=2026-09-14&end_date=2026-09-21"
Representative JSON response
{
"success": true,
"timeseries": true,
"start_date": "2026-09-14",
"end_date": "2026-09-21",
"base": "USD",
"rates": {
"2026-09-14": {
"GCG27": 0.000485
},
"2026-09-16": {
"GCG27": 0.000483
},
"2026-09-21": {
"GCG27": 0.000482
}
},
"unit": "per troy ounce"
}
Understanding the payload
timeseries: true means you received a multi-day structure.rates: An object keyed by ISO date. Each date contains a nested object keyed by symbol (here, GCG27) with ounces-per-USD rates.- Missing calendar days: Weekends/holidays may be omitted or carried as identical values. Your code should not assume every calendar day is present; iterate
Object.keys(rates)and backfill as needed.
Use cases
- Build a line chart of USD/oz: map dates to
1 / rates[date].GCG27. - Compute daily pct returns: e.g.,
ret_t = (px_t - px_{t-1}) / px_{t-1}withpxas USD/oz. - Risk metrics: rolling volatility or drawdowns over chosen windows.
Performance tips
- Batch historical windows (e.g., monthly or quarterly) in parallel, then persist to your warehouse.
- Cache immutable date windows. Store an ETag or last-modified equivalent at your application layer keyed by date range.
- Avoid repeatedly re-downloading the same history unless you intentionally refresh.
Endpoint 3: OHLC (Open/High/Low/Close) for GCG27
Purpose: Retrieve open, high, low, and close values for GCG27 on a specific date, which helps with candlestick charts, backtesting strategies using H/L breaks, or volatility approximations.
Request format
- Method: GET
- Path:
/api/open-high-low-close/YYYY-MM-DD - Query parameters:
access_key— your API keysymbols—GCG27base— optional; defaults toUSD
Example curl: GCG27 OHLC for 2026-09-21
curl "https://metals-api.com/api/open-high-low-close/2026-09-21?access_key=YOUR_API_KEY&symbols=GCG27&base=USD"
Representative JSON response
{
"success": true,
"timestamp": 1789949923,
"base": "USD",
"date": "2026-09-21",
"rates": {
"GCG27": {
"open": 0.000485,
"high": 0.000487,
"low": 0.000481,
"close": 0.000482
}
},
"unit": "per troy ounce"
}
How to use OHLC correctly
- Each field is ounces-per-USD. Invert to get USD/oz for charting and analytics.
- For daily ranges, verify which session conventions your application assumes (e.g., exchange session close vs. data vendor’s daily cut). Align across vendors if you combine sources.
- When computing volatility or ATR-like measures, prefer high/low from OHLC instead of proxying via last-trade midpoints.
Complete workflow example: Backfill, store, and serve USD/oz for GCG27
Below is a compact JavaScript example that fetches a multi-day window for GCG27, normalizes to USD per troy ounce, and logs a tidy time series. Use similar logic inside your ETL job or serverless function.
/**
* Example: Fetch and normalize GCG27 time-series to USD/oz
* Note: Store YOUR_API_KEY in an environment variable.
*/
async function fetchGCG27TimeSeries(startDate, endDate) {
const url = new URL("https://metals-api.com/api/timeseries");
url.searchParams.set("access_key", process.env.METALS_API_KEY);
url.searchParams.set("symbols", "GCG27");
url.searchParams.set("base", "USD");
url.searchParams.set("start_date", startDate);
url.searchParams.set("end_date", endDate);
const res = await fetch(url.toString(), { method: "GET", timeout: 15000 });
const data = await res.json();
if (!data.success || !data.timeseries) {
throw new Error(`Metals-API error: ${JSON.stringify(data)}`);
}
// Normalize to USD per troy ounce
const series = Object.keys(data.rates)
.sort()
.map(d => {
const ozPerUsd = data.rates[d]["GCG27"];
const usdPerOz = ozPerUsd > 0 ? (1 / ozPerUsd) : null;
return { date: d, ozPerUsd, usdPerOz };
});
return {
base: data.base,
unit: data.unit,
start: data.start_date,
end: data.end_date,
series
};
}
// Example usage:
// fetchGCG27TimeSeries("2026-09-14", "2026-09-21")
// .then(console.log)
// .catch(console.error);
What fields you actually store
date: ISO date (partition key in columnar stores)symbol: “GCG27”oz_per_usd: from APIusd_per_oz: computed 1 / oz_per_usdunit: “per troy ounce”base: “USD”ingested_at: your system timestamp
Working with troy ounces and unit conversions
Gold is priced in troy ounces (31.1034768 grams), not avoirdupois ounces. Metals-API explicitly returns “per troy ounce.” If you must present grams, kilograms, or tolas:
- grams_per_usd = oz_per_usd × 31.1034768
- usd_per_gram = 1 / grams_per_usd
Be consistent: display units alongside numbers and ensure your storage schema encodes unit metadata to avoid accidental mixing.
Timezone, date, and session cut considerations
- Timestamps in payloads are Unix epoch in UTC. When you display “as-of,” convert to user’s locale but store UTC internally.
- Historical daily snapshots correspond to date-based cuts; avoid mixing vendor clocks with exchange clocks in the same chart unless you document the convention.
- For futures like GCG27, be mindful of roll periods if you aggregate by front-month. Since we are focused on a single contract (GCG27), this guide avoids roll logic.
Caching, retries, and weekend behavior
- Immutable history: Cache by (symbol, date) for the Historical endpoint and by (symbol, start_date, end_date) for Time-series. Set TTLs generously (e.g., days) for past dates.
- Retry strategy: For transient HTTP failures, backoff with jitter. Avoid retrying on client errors (4xx) unless you’ve corrected the request.
- Weekend/holidays: Some date ranges will not contain new trading data. Your time-series logic should handle gaps gracefully—either leave missing rows or forward-fill based on your analytics requirements.
Security best practices for API integration
- Do not embed API keys in client-side code for public web apps. Proxy through your backend or use serverless functions.
- Use environment variables or secret managers (e.g., Vault, AWS Secrets Manager) for key storage.
- Scope access in internal systems; only services that require Metals-API should access the key.
- Log only high-level request metadata (symbol, date range). Avoid logging secrets or full URLs containing the key.
Data validation and sanitization
- Check
successbefore parsing. If false, inspect the error object and handle gracefully. - Validate numeric fields are finite, non-negative, and within plausible ranges. Guard against division by zero when inverting rates.
- Normalize symbol strings to uppercase; trim whitespace.
- Verify ISO date format (YYYY-MM-DD); reject or correct invalid input early in your service layer.
Error handling and recovery
- 4xx errors: Typically client-side issues (invalid key, unsupported symbol, malformed parameters). Fix and do not retry blindly.
- 5xx errors or network timeouts: Implement exponential backoff retries. Consider circuit-breakers to protect downstream services.
- Partial data in time series: If some days are missing, report coverage to users (e.g., “Data available for 5 of 7 requested days”).
Practical examples: combining Historical, Time-series, and OHLC
- Backfill last 90 trading days for GCG27 with Time-series, then augment the last 5 business days with OHLC to compute true ranges and candlesticks.
- Daily job: Pull Historical for “yesterday” and append to your warehouse. If you detect missing data over a holiday, skip and try the next business day.
- Research notebook: Use Time-series to load a window, invert to USD/oz, and build factor regressions vs. macro variables (store both oz_per_usd and usd_per_oz for easy comparisons).
Reference: Parameter quick view
| Parameter | Used In | Description | Notes |
|---|---|---|---|
| access_key | All endpoints | Your API key | Keep secret; rotate if leaked |
| symbols | Historical, Time-series, OHLC | Asset symbols (here: GCG27) | Confirm in Supported Symbols |
| base | All endpoints | Base currency (default: USD) | Rates are ounces per base unit; invert for base per ounce |
| start_date | Time-series | Inclusive window start (YYYY-MM-DD) | Use business days where possible |
| end_date | Time-series | Inclusive window end (YYYY-MM-DD) | Do not request future dates |
Putting it all together: Sample scenarios and JSON
Scenario A: Single-day historical snapshot for audit
Request:
GET /api/2026-09-20?access_key=YOUR_API_KEY&symbols=GCG27&base=USD
Response:
{
"success": true,
"timestamp": 1789863523,
"base": "USD",
"date": "2026-09-20",
"rates": {
"GCG27": 0.000485
},
"unit": "per troy ounce"
}
Notes:
- Store utc_timestamp, date, oz_per_usd, usd_per_oz=1/0.000485
Scenario B: Weekly backfill for a chart
Request:
GET /api/timeseries?access_key=YOUR_API_KEY&symbols=GCG27&base=USD&start_date=2026-09-14&end_date=2026-09-21
Response:
{
"success": true,
"timeseries": true,
"start_date": "2026-09-14",
"end_date": "2026-09-21",
"base": "USD",
"rates": {
"2026-09-14": { "GCG27": 0.000485 },
"2026-09-16": { "GCG27": 0.000483 },
"2026-09-21": { "GCG27": 0.000482 }
},
"unit": "per troy ounce"
}
Notes:
- Invert for USD/oz, plot dates vs. USD/oz.
- Missing 2026-09-15 and 2026-09-17 in the example illustrates sparse calendars—handle gracefully.
Scenario C: Daily OHLC for candlestick rendering
Request:
GET /api/open-high-low-close/2026-09-21?access_key=YOUR_API_KEY&symbols=GCG27&base=USD
Response:
{
"success": true,
"timestamp": 1789949923,
"base": "USD",
"date": "2026-09-21",
"rates": {
"GCG27": {
"open": 0.000485,
"high": 0.000487,
"low": 0.000481,
"close": 0.000482
}
},
"unit": "per troy ounce"
}
Notes:
- Build candles by inverting each OHLC field to USD/oz.
Advanced considerations: Architecture, scaling, and operations
Service design
- Build a “pricing service” microservice whose only job is to pull GCG27 and related symbols from Metals-API and expose normalized payloads (USD/oz) to internal consumers.
- Persist canonical raw JSON responses for audit, plus normalized tables for analytics (wide or long format).
- Use idempotent job scheduling (e.g., daily backfill runs) keyed by date to ensure repeatability and safe retries.
Data warehouse schema
- Core table (daily): date, symbol, base, oz_per_usd, usd_per_oz, source, unit, load_id, loaded_at
- OHLC table: date, symbol, open_oz_per_usd, high_oz_per_usd, low_oz_per_usd, close_oz_per_usd, plus inverted USD/oz columns
- Indexes/partitions: partition by date, cluster by symbol for efficient range scans
Throughput and quotas
- Batch requests: prefer Time-series for ranges over many single-day calls.
- Cache immutable results aggressively. For interactive dashboards, pre-warm with the last 30 business days for commonly queried symbols.
- Implement request coalescing to prevent thundering herds (one in-flight fetch per key).
Observability
- Metrics: request latency, error rate by endpoint, cache hit ratio, number of symbols × days fetched.
- Logs: include request IDs and date ranges. Redact keys.
- Alerts: sustained error spikes, unexpected missing dates, large gaps in time series.
Real-world applications for GCG27 data
- Pricing and hedging: Manufacturers locking input costs to a specific delivery month can compute budget rates in USD/oz and track slippage vs. actuals.
- Quant research: Analyze front-month vs. deferred-month spreads, calendar effects, and seasonality leading into February delivery.
- Fintech dashboards: Explain intraday or daily moves with OHLC snapshots and contextual historic bands.
Innovation in gold price discovery and digital transformation
Gold markets are modernizing: APIs like Metals-API make traditionally siloed, exchange-specific data programmatically accessible, enabling automation throughout the lifecycle—research, execution, and post-trade. Developers can build digital asset-like experiences on top of physical commodities: real-time notifications tied to GCG27 thresholds, portfolio VaR recalculated on new closes, and ERP pricing flows that react instantly to confirmed daily history. The effect is compounding: lower latency from data to decision, and higher consistency from a single source of normalized truth.
Next steps
- Get your key at the Metals-API Website.
- Verify
GCG27in the Supported Symbols. - Implement the Historical, Time-series, and OHLC calls shown here. Start with a small backfill window and persist normalized USD/oz.
- Scale up with caching and batching. Add monitoring and alerts as you move to production.
For full parameter details, error structures, and additional endpoints you may want later, visit the Metals-API Documentation.
FAQ
Does Metals-API return GCG27 in USD per ounce?
No. By default, rates are ounces per 1 USD (“per troy ounce” unit). Invert to get USD per ounce. You can also change the base currency, which changes the math accordingly.
How far back can I query history?
Historical rates are generally available since 2019 for most assets. Always consult the documentation and validate coverage for GCG27 specifically.
How do I handle weekends and exchange holidays?
Time-series windows may not list every calendar day. Iterate available days in the response, and forward-fill or leave gaps based on your analytics needs.
Can I call these endpoints from a front-end app directly?
It’s not recommended to expose your API key in client-side code. Proxy requests through your backend or serverless function and apply caching there.
What if I need multiple symbols or other delivery months?
Include more symbols in the symbols parameter, separated by commas, provided they’re supported in your plan. For a full list, see Metals-API Supported Symbols.
Where can I find all request/response details?
See the comprehensive Metals-API Documentation. When you’re ready, head to the Metals-API Website and get your free API key to start integrating GCG27 historical rates.