The Commodity Price API provides access to real-time commodity prices for dozens of commonly-traded commodities in major exchanges (CME, NYMEX, etc.).
https://api.api-ninjas.com/v1/commodityprice
Returns the current price information for any given commodity. All quoted prices are in USD.
name
requiredName of commodity. The supported values are:
Value | Description | Premium Only |
---|---|---|
gold | Gold Futures | No |
soybean_oil | Soybean Oil Futures | Yes |
wheat | Wheat Futures | Yes |
platinum | Platinum | No |
micro_silver | Micro Silver Futures | Yes |
lean_hogs | Lean Hogs Futures | No |
corn | Corn Futures | Yes |
oat | Oat Futures | No |
aluminum | Aluminum Futures | No |
soybean_meal | Soybean Meal Futures | No |
silver | Silver Futures | Yes |
soybean | Soybean Futures | Yes |
lumber | Lumber Futures | No |
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 | No |
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 | Yes |
X-Api-Key
requiredAPI Key associated with your account.
https://api.api-ninjas.com/v1/commodityprice?name=platinum
1
2
3
4
5
6
{
"exchange": "NYMEX",
"name": "Platinum",
"price": 995.05,
"updated": 1728677095
}
1
2
3
4
5
6
7
8
9
import requests
name = 'platinum'
api_url = 'https://api.api-ninjas.com/v1/commodityprice?name={}'.format(name)
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.