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.
name
requiredName of commodity. The supported values are:
Value | Description |
---|---|
gold | Gold Futures |
soybean_oil | Soybean Oil Futures |
wheat | Wheat Futures |
platinum | Platinum |
micro_silver | Micro Silver Futures |
lean_hogs | Lean Hogs Futures |
corn | Corn Futures |
oat | Oat Futures |
aluminum | Aluminum Futures |
soybean_meal | Soybean Meal Futures |
silver | Silver Futures |
soybean | Soybean Futures |
lumber | Lumber Futures |
live_cattle | Live Cattle Futures |
sugar | Sugar |
natural_gas | Natural Gas |
crude_oil | Crude Oil |
orange_juice | Orange Juice |
coffee | Coffee |
cotton | Cotton |
copper | Copper |
micro_gold | Micro Gold Futures |
feeder_cattle | Feeder Cattle Futures |
rough_rice | Rough Rice Futures |
palladium | Palladium |
coca | Cocoa |
brent_crude_oil | Brent Crude Oil |
gasoline_rbob | Gasoline RBOB |
heating_oil | Heating Oil |
class_3_milk | Class III Milk Futures |
X-Api-Key
requiredAPI Key associated with your account.
https://api.api-ninjas.com/v1/commodityprice?name=silver
1
2
3
4
5
6
{
"exchange": "CME",
"name": "Silver Futures",
"price": 26.785,
"updated": 1714769996
}
1
2
3
4
5
6
7
8
9
import requests
name = 'silver'
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.