The Gold Price API provides access to real-time gold futures price in the Chicago Mercantile Exchange (CME).
For other commodity prices, please check out our Commodity Price API.
https://api.api-ninjas.com/v1/goldprice
Returns the current gold futures price in USD. For historical gold futures prices, see /v1/goldpricehistorical.
None
X-Api-Key
requiredAPI Key associated with your account.
price
The current gold futures price in USD.
timestamp
The timestamp of the gold futures price in Unix format (in seconds).
https://api.api-ninjas.com/v1/goldprice
Headers
X-Api-Key
Log in or sign up to get your API Key
1
2
3
4
{
"price": 2310.1,
"updated": 1714769998
}
1
2
3
4
5
6
7
import requests
api_url = 'https://api.api-ninjas.com/v1/goldprice'
response = requests.get(api_url, headers={'X-Api-Key': 'YOUR_API_KEY'})
if response.status_code == requests.codes.ok:
print(response.text)
else:
print("Error:", response.status_code, response.text)
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.
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.
period
optionalTime interval between data points. Valid values are: 1m
, 5m
, 15m
, 30m
, 1h
, 4h
, 1d
. Default is 1h
.
start
optionalStart timestamp in Unix format. If not provided, defaults to 24 hours ago.
end
optionalEnd timestamp in Unix format. If not provided, defaults to current time.
X-Api-Key
requiredAPI Key associated with your account.
open
The opening price for this time period in USD.
low
The lowest price during this time period in USD.
high
The highest price during this time period in USD.
close
The closing price for this time period in USD.
volume
The trading volume during this time period.
time
The timestamp for this data point in Unix format (in seconds).
https://api.api-ninjas.com/v1/goldpricehistorical?period=1h&start=1706000000&end=1706302801
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
[
{
"open": 2624.7,
"low": 2621.4,
"high": 2626.3,
"close": 2622.3,
"volume": 1640,
"time": 1732582800
},
{
"open": 2626.5,
"low": 2617.1,
"high": 2626.5,
"close": 2624.7,
"volume": 2986,
"time": 1732579200
},
{
"open": 2630.2,
"low": 2625.2,
"high": 2631.6,
"close": 2626.6,
"volume": 1191,
"time": 1732575600
},
"..."
]