NewConnect Claude, Gemini, ChatGPT, and other AI agents to API Ninjas via our MCP server

Gold Price History

Gold Price APIUpdated August 28, 2026
Create a free API key and it will be pre-filled into every code sample on this page. No credit card required.
Gold has climbed from a fixed $35 per troy ounce in 1971 to above $4,000 in 2026 — with two decade-long bear markets on the way. This page covers both halves of the story: the key milestones in gold price history, and the working Python to pull the full price series yourself — current price and historical OHLCV candles — from the Gold Price API.

Gold price history at a glance

Approximate market levels in nominal US dollars per troy ounce at each turning point:

YearPriceWhat happened
1971$35–44The US ends dollar convertibility; the fixed $35 peg dissolves and gold trades freely.
1980~$850Double-digit inflation and oil shocks drive the spike that remained the inflation-adjusted record for decades.
1999~$250The bottom of a 20-year bear market amid central-bank selling and an equity boom.
2011~$1,895Post-financial-crisis peak during quantitative easing and the European debt crisis.
2020~$2,070Pandemic stimulus and negative real yields set a new nominal high.
2024$2,700+Record central-bank buying and rate-cut expectations power a breakout.
2026$4,000+The rally extends; gold trades above $4,000 for the first time.

The recurring drivers behind those moves: real interest rates (gold pays no yield, so it shines when inflation-adjusted rates fall), the strength of the US dollar, central-bank reserve buying, and crisis demand for a haven.

Prerequisites

To pull the data yourself you need three things:

  • Python 3.8 or newer.
  • The requests library, plus matplotlib if you want the chart step.
  • A free API Ninjas API key — issued instantly, no credit card. If you already have an account, it's on your profile page.
shell
pip install requests matplotlib

Step 1: Get the current price

/v1/goldprice takes no parameters — just the API key header:

gold_now.py
import requests response = requests.get( 'https://api.api-ninjas.com/v1/goldprice', headers={'X-Api-Key': 'YOUR_API_KEY'}, timeout=10, ) response.raise_for_status() gold = response.json() print(f"Gold: ${gold['price']:,} per troy ounce") # Gold: $4,305.6 per troy ounce
api.api-ninjas.com
GET/v1/goldprice
200 OKapplication/json
{ "price": 4305.6, "unit": "troy_ounce", "currency_unit": "USD", "updated": 1786044078 }

The price is USD per troy ounce and updated is the Unix timestamp of the quote. It tracks COMEX gold futures — the benchmark price the headlines quote.

Step 2: Pull historical candles

/v1/goldpricehistorical returns OHLCV candles — open, high, low, close, volume — newest first, so sort by time before doing anything else:

gold_history.py
import os import requests session = requests.Session() session.headers['X-Api-Key'] = os.environ.get('API_NINJAS_KEY', 'YOUR_API_KEY') candles = session.get( 'https://api.api-ninjas.com/v1/goldpricehistorical', params={'period': '1d'}, timeout=10, ).json() candles.sort(key=lambda c: c['time']) # API returns newest first print(f"{len(candles)} daily candles, latest close ${candles[-1]['close']:,}")
api.api-ninjas.com
GET/v1/goldpricehistorical?period=1d
200 OKapplication/json
[ { "open": 4302.1, "low": 4301.8, "high": 4309.7, "close": 4306.2, "volume": 898, "time": 1786028400 }, { "open": 4306, "low": 4299.5, "high": 4308, "close": 4302, "volume": 2215, "time": 1786024800 } ]

Three optional parameters shape the series:

ParameterValuesMeaning
period1m1dCandle interval: 1m, 5m, 15m, 30m, 1h (default), 4h, 1d.
startUnix secondsStart of the range.
endUnix secondsEnd of the range.

For a specific window, convert dates to timestamps:

range.py
import time from datetime import datetime, timezone start = int(datetime(2026, 1, 1, tzinfo=timezone.utc).timestamp()) end = int(time.time()) candles = session.get( 'https://api.api-ninjas.com/v1/goldpricehistorical', params={'period': '1d', 'start': start, 'end': end}, timeout=10, ).json()

Step 3: Chart the history

With sorted candles, a line chart of closes is a dozen lines of matplotlib:

chart.py
from datetime import datetime, timezone import matplotlib.pyplot as plt candles.sort(key=lambda c: c['time']) dates = [datetime.fromtimestamp(c['time'], tz=timezone.utc) for c in candles] closes = [c['close'] for c in candles] plt.figure(figsize=(10, 5)) plt.plot(dates, closes) plt.title('Gold price history (USD per troy ounce)') plt.ylabel('Close (USD)') plt.grid(alpha=0.3) plt.tight_layout() plt.savefig('gold_price_history.png')

Step 4: Export to CSV

For Excel, Google Sheets, or a database load, write the candles straight out:

to_csv.py
import csv candles.sort(key=lambda c: c['time']) with open('gold_price_history.csv', 'w', newline='') as f: writer = csv.DictWriter(f, fieldnames=['time', 'open', 'high', 'low', 'close', 'volume']) writer.writeheader() writer.writerows(candles) print(f'Wrote {len(candles)} rows')

Where to go from here

The same request pattern covers the rest of the metals and energy complex: the Commodity Price API for silver, platinum, copper, and wheat, and the Oil Price API for WTI and Brent. For equities, the Stock Price API uses the identical OHLCV historical shape. The complete script is below.

gold_prices.py

The complete script from this guide: current price, or historical candles for any period exported to CSV.

Frequently asked questions

What was the highest gold price ever?

In nominal US dollars, gold set its all-time highs in the mid-2020s, trading above $4,000 per troy ounce in 2026. Adjusted for inflation, the January 1980 spike to around $850 held the effective record for decades.

Is the API price spot or futures?

The Gold Price API tracks the COMEX gold futures price — the most-quoted benchmark for gold. Spot and near-term futures typically trade within a few dollars of each other.

What units are gold prices quoted in?

US dollars per troy ounce, the global standard. One troy ounce is about 31.103 grams — slightly heavier than a regular ounce.

How often is the price updated?

Continuously while the futures market trades. Free-tier responses are delayed; premium plans receive the latest available price. COMEX pauses briefly each weekday afternoon and closes over the weekend.

What intervals does the historical endpoint support?

Seven: 1m, 5m, 15m, 30m, 1h, 4h, and 1d (default 1h). Use intraday intervals for recent trading detail and 1d for long-run history.

Can I get silver and other metals the same way?

Yes — the Commodity Price API covers silver, platinum, palladium, copper, and dozens more with the same request pattern and the same API key.