Gold Price API
The Gold Price API provides access to current and historical gold prices: the live gold spot price (XAU/USD) with bid and ask, and the COMEX gold futures price and contract, in USD or any other currency, per troy ounce, gram, or kilogram.
Available endpoints:
- /v1/goldprice - Access the current gold futures price
- /v1/goldspot - Access the current gold spot price (XAU/USD)
- /v1/goldpricehistorical - Access historical gold prices
For silver, platinum, palladium, and copper, see the Metals Price API; for other commodity prices, please check out our Commodity Price API.
Premium members get the live price; free users get the last completed daily settlement.
From 4,675 users
Applications using this API
API Status
API Response Times
Average | P50 | P75 | P90 | P95 |
|---|---|---|---|---|
| 269ms | 298ms | 357ms | 720ms | 1033ms |
Didn't find what you were looking for? Suggest an improvement
https://api.api-ninjas.com/v1/goldprice
Returns the current gold futures price in USD. Premium members get the live price; free users get the last completed daily settlement. For the gold spot price, see /v1/goldspot; for historical gold futures prices, see /v1/goldpricehistorical.
Parameters
currencyoptionalISO 4217 currency code to convert the price into (e.g.
EUR,GBP). Defaults to USD.unitoptionalTarget unit to convert the price into. One of
troy_ounce(default),g,kg,oz,lb,metric_ton,short_ton, orhundredweight.
Headers
X-Api-KeyrequiredAPI Key associated with your account.
Response
The /v1/goldprice endpoint returns a JSON object with the following fields, or an error if the request is unsuccessful.
priceThe current gold futures price (in USD per troy ounce by default; see the
currencyandunitparameters).unitThe quote unit (
troy_ounceby default; changes when theunitparameter is used).currency_unitThe price currency (
USDby default; changes when thecurrencyparameter is used).updatedThe timestamp at which the gold futures price was last updated, in Unix format (in seconds).
futures_contractThe COMEX contract
priceis quoted for (e.g.GCZ26, December 2026).futures_contract_monthThe contract's delivery month (
YYYY-MM).
Live Demo
Get a free API key to get started — no credit card required.
Code Examples
curl -X GET "https://api.api-ninjas.com/v1/goldprice" \
-H "X-Api-Key: YOUR_API_KEY"If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.
Premium only
https://api.api-ninjas.com/v1/goldspot
Returns the gold spot price (XAU/USD), the price of gold for immediate delivery, with bid and ask. Gold futures normally trade slightly above spot; for the futures price, see /v1/goldprice.
Update frequency: every minute on Developer plans and about every 10 seconds on Business plans and above.
Parameters
currencyoptionalISO 4217 currency code to convert prices into (e.g.
EUR,GBP,INR). Defaults to USD.unitoptionalTarget unit:
troy_ounce(default),g,kg,oz,lb,metric_ton,short_ton, orhundredweight.
Headers
X-Api-KeyrequiredAPI Key associated with your account.
Response
The /v1/goldspot endpoint returns a JSON object with the following fields, or an error if the request is unsuccessful.
priceThe gold spot price (XAU/USD), in USD per troy ounce by default.
bidThe spot bid price.
askThe spot ask price.
spot_typeHow the spot price is produced:
composite(a live spot price).previous_closeThe previous session's closing spot price.
change_24hThe change versus the previous close.
change_24h_percentThe percent change versus the previous close.
high_24hThe session's high price.
low_24hThe session's low price.
market_statusopenorclosed. Gold trades from Sunday 6 PM to Friday 5 PM ET, with a daily break from 5 to 6 PM ET.updatedThe Unix timestamp (in seconds) of the spot price.
unitThe quote unit (changes when the
unitparameter is used).currency_unitThe price currency (
USDby default).
Live Demo
Code Examples
curl -X GET "https://api.api-ninjas.com/v1/goldspot" \
-H "X-Api-Key: YOUR_API_KEY"Premium only
https://api.api-ninjas.com/v1/goldpricehistorical
Returns historical gold futures price data in OHLCV (Open, High, Low, Close, Volume) format. The data is returned in descending order (most recent first), and all prices are in USD.
Parameters
periodoptionalTime interval between data points. Valid values are:
1m,5m,15m,30m,1h,4h,1d. Default is1h.startoptionalStart timestamp in Unix format. If not provided, defaults to 24 hours ago.
endoptionalEnd timestamp in Unix format. If not provided, defaults to current time.
Headers
X-Api-KeyrequiredAPI Key associated with your account.
Response
The /v1/goldpricehistorical endpoint returns a JSON array of objects, each with the following fields, or an error if the request is unsuccessful.
openThe opening price for this time period in USD.
lowThe lowest price during this time period in USD.
highThe highest price during this time period in USD.
closeThe closing price for this time period in USD.
volumeThe trading volume during this time period.
timeThe timestamp for this data point in Unix format (in seconds).
Live Demo
Code Examples
curl -X GET "https://api.api-ninjas.com/v1/goldpricehistorical?period=1h" \
-H "X-Api-Key: YOUR_API_KEY"Frequently Asked Questions
Can I use the Gold Price API for commercial purposes?
Yes, but you must have a premium subscription. Commercial use of the Gold Price API is not permitted on the free tier. See our pricing page to choose a plan that fits your needs.How do I get an API key and start using the Gold Price API?
Sign up for a free account to instantly get your API key, then pass it in theX-Api-Keyheader on every request. The documentation above includes ready-to-run examples in cURL, Python, JavaScript, Node.js, and more.What happens if I exceed my quota for the month?
Your API requests will simply be denied once you hit your monthly quota — you will never be charged more than the plan you signed up for. To increase your quota, you can upgrade your plan any time on our pricing page.What happens if a request to the Gold Price API fails?
The API responds with a standard HTTP status code and a JSON error message describing the problem. See our error codes reference for the full list of codes and how to resolve each one, or contact support if you need help.What endpoints does the Gold Price API offer?
The Gold Price API has three endpoints:/v1/goldpricereturns the current gold futures price in USD and the contract it is quoted for,/v1/goldspotreturns the gold spot price (XAU/USD, withbidandask; premium plans only), and/v1/goldpricehistoricalreturns historical gold futures prices in OHLCV format. For silver, platinum, palladium, and copper, see the Metals Price API; for other commodities, see the Commodity Price API.What is the difference between /v1/goldprice and /v1/goldspot?
/v1/goldpricereturns the COMEX gold futures price for the contract named infutures_contract(e.g.GCZ26, December 2026)./v1/goldspotreturns the price of gold for immediate delivery (XAU/USD), withbidandask; futures normally trade slightly above spot. Both acceptcurrencyandunit, for example gold per gram in EUR.How fresh is the gold price data, and what determines whether I get live prices?
Premium members get live gold futures prices from/v1/goldpriceand live spot prices from/v1/goldspot(refreshed every minute on Developer plans and about every 10 seconds on Business plans and above). Free users receive the last completed daily futures settlement from/v1/goldprice;/v1/goldspotis premium only. Theupdatedfield always carries the timestamp of the price itself, so you can tell exactly which session a quote belongs to. See the pricing page for the plans that unlock live prices.How do I request historical gold prices for a specific time range and interval?
Call/v1/goldpricehistoricalwith the optionalperiodparameter (valid values1m,5m,15m,30m,1h,4h,1d; default1h) plusstartandendUnix timestamps; if omitted,startdefaults to 24 hours ago andendto the current time. You can try it live after you register.What fields does the historical endpoint response include?
Each data point returnsopen,high,low, andcloseprices in USD, along withvolumeand atimeUnix timestamp, ordered most recent first; a failed request instead returns an error.
Explore API integration use cases for recommended APIs and workflow examples.