Commodity Price API
The Commodity Price API provides access to real-time commodity prices for dozens of commonly-traded commodities in major exchanges (CME, NYMEX, etc.).
/v1/commodityprice GET
https://api.api-ninjas.com/v1/commodityprice
Returns the current price information for any given commodity. All quoted prices are in USD.
For historical commodity prices, see /v1/commoditypricehistorical.
Parameters
- namerequired- Name of commodity. The supported values are: - Value - Description - Premium Only - gold- Gold Futures - Yes - soybean_oil- Soybean Oil Futures - Yes - wheat- Wheat Futures - Yes - platinum- Platinum - No - micro_silver- Micro Silver Futures - No - lean_hogs- Lean Hogs Futures - Yes - corn- Corn Futures - Yes - oat- Oat Futures - No - aluminum- Aluminum Futures - Yes - soybean_meal- Soybean Meal Futures - Yes - silver- Silver Futures - Yes - soybean- Soybean Futures - Yes - lumber- Lumber Futures - Yes - live_cattle- Live Cattle Futures - Yes - sugar- Sugar - Yes - natural_gas- Natural Gas - Yes - crude_oil- Crude Oil - Yes - orange_juice- Orange Juice - Yes - coffee- Coffee - Yes - cotton- Cotton - Yes - copper- Copper - Yes - micro_gold- Micro Gold Futures - No - feeder_cattle- Feeder Cattle Futures - No - rough_rice- Rough Rice Futures - No - palladium- Palladium - Yes - cocoa- Cocoa - Yes - brent_crude_oil- Brent Crude Oil - Yes - gasoline_rbob- Gasoline RBOB - Yes - heating_oil- Heating Oil - Yes - class_3_milk- Class III Milk Futures - No 
Headers
- X-Api-Keyrequired- API Key associated with your account. 
Response
- exchange- The symbol of the exchange where the commodity is traded. 
- name- The name of the commodity. 
- price- The current price of the commodity in USD. 
- updated- The Unix timestamp of the price update. 
Sample Request Live Demo!
https://api.api-ninjas.com/v1/commodityprice?name=platinumHeaders
X-Api-KeyLog in or sign up to get your API KeySample Response
1
2
3
4
5
6
{
  "exchange": "NYMEX",
  "name": "Platinum",
  "price": 995.05,
  "updated": 1728677095
}Code Examples
1
2
curl -X GET "https://api.api-ninjas.com/v1/commodityprice?name=gold" \
  -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.
/v1/commoditypricehistorical GET Premium Only
https://api.api-ninjas.com/v1/commoditypricehistorical
Returns historical commodity 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
- namerequired- Name of commodity. Use the same values as the name parameter in /v1/commodityprice. 
- periodoptional- Time interval between data points. Valid values are: - 1m,- 5m,- 15m,- 30m,- 1h,- 4h,- 1d. Default is- 1h.
- startoptional- Start timestamp in Unix format. If not provided, defaults to 24 hours ago. 
- endoptional- End timestamp in Unix format. If not provided, defaults to current time. 
Headers
- X-Api-Keyrequired- API Key associated with your account. 
Response
- open- The opening price of the commodity in USD. 
- low- The lowest price of the commodity in USD. 
- high- The highest price of the commodity in USD. 
- close- The closing price of the commodity in USD. 
- volume- The volume of the commodity. 
- time- The Unix timestamp of the price update. 
Historical Price Sample Request
https://api.api-ninjas.com/v1/commoditypricehistorical?name=gold&period=1h&start=1728677095&end=1729677095Historical Price Sample Response
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": 2757.2,
    "low": 2745.4,
    "high": 2758,
    "close": 2751.2,
    "volume": 29068,
    "time": 1729674000
  },
  {
    "open": 2763.9,
    "low": 2754.5,
    "high": 2764.5,
    "close": 2757.3,
    "volume": 16722,
    "time": 1729670400
  },
  {
    "open": 2764.6,
    "low": 2763,
    "high": 2767,
    "close": 2763.9,
    "volume": 5495,
    "time": 1729666800
  },
  "..."
]