# Get Commodity Details
Get detailed information about a specific commodity including current price, metadata, and trading information.
# Endpoint
GET /v1/commodities/{code}
# Parameters
Parameter | Type | Required | Description |
---|---|---|---|
code | string | Yes | The commodity code (e.g., WTI_USD , BRENT_CRUDE_USD ) |
# Headers
Header | Value | Required |
---|---|---|
Authorization | Token YOUR_API_KEY | Yes |
Content-Type | application/json | Yes |
# Response
# Success Response (200 OK)
{
"status": "success",
"data": {
"code": "WTI_USD",
"name": "West Texas Intermediate Crude Oil",
"category": "crude_oil",
"unit": "barrel",
"currency": "USD",
"decimal_places": 2,
"description": "WTI is a grade of crude oil used as a benchmark in oil pricing",
"exchange": "NYMEX",
"current_price": {
"value": 78.45,
"formatted": "$78.45",
"currency": "USD",
"last_updated": "2025-01-10T15:30:00.000Z"
},
"metadata": {
"contract_size": 1000,
"tick_size": 0.01,
"trading_hours": "Sunday - Friday: 6:00 PM - 5:00 PM ET",
"settlement": "Physical delivery",
"api_code": "CL"
},
"price_limits": {
"min": 10.0,
"max": 200.0,
"typical_range": {
"low": 40.0,
"high": 100.0
}
}
}
}
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
28
29
30
31
32
33
34
# Error Response (404 Not Found)
{
"status": "fail",
"error": {
"code": "COMMODITY_NOT_FOUND",
"message": "Commodity not found",
"commodity_code": "INVALID_CODE"
}
}
2
3
4
5
6
7
8
# Code Examples
# cURL
# Get WTI crude oil details
curl "https://api.oilpriceapi.com/v1/commodities/WTI_USD" \
-H "Authorization: Token YOUR_API_KEY"
# Get Brent crude details
curl "https://api.oilpriceapi.com/v1/commodities/BRENT_CRUDE_USD" \
-H "Authorization: Token YOUR_API_KEY"
# Get natural gas details
curl "https://api.oilpriceapi.com/v1/commodities/NATURAL_GAS_USD" \
-H "Authorization: Token YOUR_API_KEY"
2
3
4
5
6
7
8
9
10
11
# Python
import requests
api_key = "YOUR_API_KEY"
commodity_code = "WTI_USD"
response = requests.get(
f"https://api.oilpriceapi.com/v1/commodities/{commodity_code}",
headers={"Authorization": f"Token {api_key}"}
)
if response.status_code == 200:
data = response.json()
commodity = data['data']
print(f"{commodity['name']}: {commodity['current_price']['formatted']}")
else:
print(f"Error: {response.status_code}")
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# JavaScript
const apiKey = 'YOUR_API_KEY';
const commodityCode = 'WTI_USD';
fetch(`https://api.oilpriceapi.com/v1/commodities/${commodityCode}`, {
headers: {
'Authorization': `Token ${apiKey}`
}
})
.then(response => response.json())
.then(data => {
if (data.status === 'success') {
const commodity = data.data;
console.log(`${commodity.name}: ${commodity.current_price.formatted}`);
}
})
.catch(error => console.error('Error:', error));
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Ruby
require 'net/http'
require 'json'
api_key = 'YOUR_API_KEY'
commodity_code = 'WTI_USD'
uri = URI("https://api.oilpriceapi.com/v1/commodities/#{commodity_code}")
request = Net::HTTP::Get.new(uri)
request['Authorization'] = "Token #{api_key}"
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
if response.code == '200'
data = JSON.parse(response.body)
commodity = data['data']
puts "#{commodity['name']}: #{commodity['current_price']['formatted']}"
end
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# PHP
<?php
$apiKey = 'YOUR_API_KEY';
$commodityCode = 'WTI_USD';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.oilpriceapi.com/v1/commodities/{$commodityCode}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Token {$apiKey}"
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode === 200) {
$data = json_decode($response, true);
$commodity = $data['data'];
echo "{$commodity['name']}: {$commodity['current_price']['formatted']}\n";
}
?>
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Available Commodity Codes
For a complete list of available commodity codes, see the List Commodities endpoint.
# Common Codes
- Crude Oil:
WTI_USD
,BRENT_CRUDE_USD
,DUBAI_CRUDE_USD
- Natural Gas:
NATURAL_GAS_USD
,NATURAL_GAS_EUR
,NATURAL_GAS_GBP
- Refined Products:
RBOB_GASOLINE_USD
,GASOLINE_USD
,DIESEL_USD
- Marine Fuels:
MGO_05S_USD
,VLSFO_USD
,HSFO_USD
# Rate Limits
This endpoint counts against your monthly API request limit. Check the response headers for current usage:
X-RateLimit-Limit
: Your monthly limitX-RateLimit-Remaining
: Requests remaining this monthX-RateLimit-Reset
: When the limit resets (Unix timestamp)
# Notes
- Prices are updated every 5 minutes during market hours
- Historical data retention varies by commodity
- Some commodities may have limited metadata depending on the source
- Marine fuel prices include IMO 2020 compliance information
# Commodity-Specific Examples
# WTI USD
West Texas Intermediate - The primary US crude oil benchmark
curl "https://api.oilpriceapi.com/v1/commodities/WTI_USD" \
-H "Authorization: Token YOUR_API_KEY"
# Get latest WTI price
curl "https://api.oilpriceapi.com/v1/prices/latest?by_code=WTI_USD" \
-H "Authorization: Token YOUR_API_KEY"
2
3
4
5
6
# BRENT CRUDE USD
Brent Crude - The global crude oil benchmark
curl "https://api.oilpriceapi.com/v1/commodities/BRENT_CRUDE_USD" \
-H "Authorization: Token YOUR_API_KEY"
# Get Brent in EUR
curl "https://api.oilpriceapi.com/v1/prices/latest?by_code=BRENT_CRUDE_USD¤cy=EUR" \
-H "Authorization: Token YOUR_API_KEY"
2
3
4
5
6
# NATURAL GAS USD
Henry Hub Natural Gas - US natural gas benchmark
curl "https://api.oilpriceapi.com/v1/commodities/NATURAL_GAS_USD" \
-H "Authorization: Token YOUR_API_KEY"
# Get past week of natural gas prices
curl "https://api.oilpriceapi.com/v1/prices/past_week?by_code=NATURAL_GAS_USD" \
-H "Authorization: Token YOUR_API_KEY"
2
3
4
5
6
# GASOLINE RBOB USD
RBOB Gasoline - Reformulated Blendstock for Oxygenate Blending
curl "https://api.oilpriceapi.com/v1/commodities/GASOLINE_RBOB_USD" \
-H "Authorization: Token YOUR_API_KEY"
# Compare with diesel
curl "https://api.oilpriceapi.com/v1/prices/latest?by_code=GASOLINE_RBOB_USD,ULSD_DIESEL_USD" \
-H "Authorization: Token YOUR_API_KEY"
2
3
4
5
6
# ULSD DIESEL USD
Ultra-Low Sulfur Diesel - Highway diesel fuel standard
curl "https://api.oilpriceapi.com/v1/commodities/ULSD_DIESEL_USD" \
-H "Authorization: Token YOUR_API_KEY"
2
# JET FUEL USD
Jet Fuel - Aviation turbine fuel
curl "https://api.oilpriceapi.com/v1/commodities/JET_FUEL_USD" \
-H "Authorization: Token YOUR_API_KEY"
2
# HEATING OIL USD
Heating Oil - Residential and commercial heating fuel
curl "https://api.oilpriceapi.com/v1/commodities/HEATING_OIL_USD" \
-H "Authorization: Token YOUR_API_KEY"
2
# NATURAL GAS GBP
UK Natural Gas (NBP) - UK natural gas benchmark (priced in pence/therm)
curl "https://api.oilpriceapi.com/v1/commodities/NATURAL_GAS_GBP" \
-H "Authorization: Token YOUR_API_KEY"
2
# DUTCH TTF EUR
Dutch TTF Natural Gas - European natural gas benchmark
curl "https://api.oilpriceapi.com/v1/commodities/DUTCH_TTF_EUR" \
-H "Authorization: Token YOUR_API_KEY"
2
# COAL USD
Newcastle Coal - Thermal coal benchmark price
curl "https://api.oilpriceapi.com/v1/commodities/COAL_USD" \
-H "Authorization: Token YOUR_API_KEY"
2
# EU CARBON EUR
EU Carbon Allowances - EU Emissions Trading System
curl "https://api.oilpriceapi.com/v1/commodities/EU_CARBON_EUR" \
-H "Authorization: Token YOUR_API_KEY"
2
# URANIUM USD
Uranium U3O8 - Nuclear fuel commodity
curl "https://api.oilpriceapi.com/v1/commodities/URANIUM_USD" \
-H "Authorization: Token YOUR_API_KEY"
2
# ETHANOL USD
Ethanol - Biofuel additive
curl "https://api.oilpriceapi.com/v1/commodities/ETHANOL_USD" \
-H "Authorization: Token YOUR_API_KEY"
2
# DUBAI CRUDE USD
Dubai Crude - Middle East crude oil benchmark
curl "https://api.oilpriceapi.com/v1/commodities/DUBAI_CRUDE_USD" \
-H "Authorization: Token YOUR_API_KEY"
2
# URALS CRUDE USD
Urals Crude - Russian crude oil benchmark
curl "https://api.oilpriceapi.com/v1/commodities/URALS_CRUDE_USD" \
-H "Authorization: Token YOUR_API_KEY"
2
# WCS CRUDE USD
Western Canadian Select - Canadian heavy crude oil
curl "https://api.oilpriceapi.com/v1/commodities/WCS_CRUDE_USD" \
-H "Authorization: Token YOUR_API_KEY"
2
# JKM LNG USD
Japan Korea Marker - Asian LNG benchmark
curl "https://api.oilpriceapi.com/v1/commodities/JKM_LNG_USD" \
-H "Authorization: Token YOUR_API_KEY"
2