Get all available commodity prices in a single API call. This endpoint returns current prices for 40+ energy commodities, metals, and forex pairs, making it ideal for dashboards, market overviews, and reducing API calls.
Access Level: Available to all tiers (request limits apply)
Requires API key authentication:
curl -X GET "https://api.oilpriceapi.com/v1/prices/all" \
-H "Authorization: Token YOUR_API_KEY" \
-H "Accept: application/json"
Parameter | Type | Description | Example |
---|
categories | string | Comma-separated list of categories to filter | oil,gas,metals |
codes | string | Comma-separated list of specific commodity codes | WTI_USD,BRENT_CRUDE_USD,GOLD_USD |
include_metadata | boolean | Include additional metadata for each commodity | true |
{
"status": "success",
"data": {
"prices": [
{
"code": "WTI_USD",
"name": "WTI Crude Oil",
"price": 72.45,
"currency": "USD",
"unit": "barrel",
"category": "oil",
"change_24h": 0.85,
"change_24h_percent": 1.19,
"last_updated": "2025-09-22T14:30:00Z"
},
{
"code": "BRENT_CRUDE_USD",
"name": "Brent Crude Oil",
"price": 76.32,
"currency": "USD",
"unit": "barrel",
"category": "oil",
"change_24h": 0.92,
"change_24h_percent": 1.22,
"last_updated": "2025-09-22T14:30:00Z"
},
{
"code": "NATURAL_GAS_USD",
"name": "Natural Gas (Henry Hub)",
"price": 2.85,
"currency": "USD",
"unit": "mmBtu",
"category": "gas",
"change_24h": -0.03,
"change_24h_percent": -1.04,
"last_updated": "2025-09-22T14:30:00Z"
},
{
"code": "GOLD_USD",
"name": "Gold",
"price": 1923.45,
"currency": "USD",
"unit": "oz",
"category": "metals",
"change_24h": 5.20,
"change_24h_percent": 0.27,
"last_updated": "2025-09-22T14:30:00Z"
}
],
"metadata": {
"total_commodities": 42,
"timestamp": "2025-09-22T14:30:00Z",
"cache_time": 60,
"categories_included": ["oil", "gas", "metals", "forex", "marine_fuels"],
"update_frequency": "5 minutes"
}
}
}
Code | Name | Unit |
---|
WTI_USD | WTI Crude Oil | USD/barrel |
BRENT_CRUDE_USD | Brent Crude Oil | USD/barrel |
DUBAI_CRUDE_USD | Dubai Crude | USD/barrel |
TAPIS_CRUDE_USD | Tapis Crude | USD/barrel |
WCS_CRUDE_USD | Western Canada Select | USD/barrel |
URALS_CRUDE_USD | Urals Crude | USD/barrel |
GASOLINE_RBOB_USD | RBOB Gasoline | USD/gallon |
HEATING_OIL_USD | Heating Oil | USD/gallon |
JET_FUEL_USD | Jet Fuel | USD/gallon |
ULSD_DIESEL_USD | ULSD Diesel | USD/gallon |
Code | Name | Unit |
---|
NATURAL_GAS_USD | Henry Hub Natural Gas | USD/mmBtu |
NATURAL_GAS_GBP | UK Natural Gas | GBp/therm |
DUTCH_TTF_EUR | Dutch TTF Gas | EUR/MWh |
JKM_LNG_USD | Japan/Korea LNG | USD/mmBtu |
NATURAL_GAS_STORAGE | US Gas Storage | Bcf |
Code | Name | Unit |
---|
VLSFO_USD | Very Low Sulfur Fuel Oil (Global) | USD/MT |
HFO_380_USD | Heavy Fuel Oil 380 CST (Global) | USD/MT |
MGO_05S_USD | Marine Gas Oil 0.5%S (Global) | USD/MT |
HFO_380_NLRTM_USD | HFO 380 Rotterdam | USD/MT |
VLSFO_SGSIN_USD | VLSFO Singapore | USD/MT |
MGO_05S_USHOU_USD | MGO Houston | USD/MT |
VLSFO_AEFUJ_USD | VLSFO Fujairah | USD/MT |
Code | Name | Unit |
---|
GOLD_USD | Gold | USD/oz |
URANIUM_USD | Uranium U308 | USD/lb |
Code | Name | Unit |
---|
COAL_USD | Newcastle Coal | USD/MT |
ETHANOL_USD | Ethanol | USD/gallon |
EU_CARBON_EUR | EU Carbon Credits | EUR/tonne |
Code | Name | Unit |
---|
GBP_USD | British Pound | USD |
EUR_USD | Euro | USD |
Code | Name | Unit |
---|
US_RIG_COUNT | US Rig Count | rigs |
CANADA_RIG_COUNT | Canada Rig Count | rigs |
CUSHING_STORAGE | Cushing Oil Storage | million barrels |
GET /v1/prices/all?categories=oil,gas
GET /v1/prices/all?codes=WTI_USD,BRENT_CRUDE_USD,NATURAL_GAS_USD,GOLD_USD
GET /v1/prices/all?include_metadata=true
Monitor data freshness for all commodities:
GET /v1/prices/all/health
Response:
{
"status": "healthy",
"data": {
"total_commodities": 42,
"fresh_data": 40,
"stale_data": 2,
"stale_commodities": [
{
"code": "COAL_USD",
"last_updated": "2025-09-22T08:00:00Z",
"hours_old": 6.5
}
],
"average_age_minutes": 12,
"last_full_update": "2025-09-22T14:25:00Z"
}
}
async function updateDashboard() {
const response = await fetch('https://api.oilpriceapi.com/v1/prices/all', {
headers: {
'Authorization': 'Token YOUR_API_KEY'
}
});
const data = await response.json();
const grouped = data.data.prices.reduce((acc, item) => {
if (!acc[item.category]) acc[item.category] = [];
acc[item.category].push(item);
return acc;
}, {});
grouped.oil.forEach(commodity => {
console.log(`${commodity.name}: $${commodity.price} ${commodity.change_24h_percent > 0 ? 'š' : 'š'}`);
});
}
import websocket
import json
import threading
class PriceAlertSystem:
def __init__(self, api_key, alert_threshold=2.0):
self.api_key = api_key
self.alert_threshold = alert_threshold
self.ws = None
def on_message(self, ws, message):
data = json.loads(message)
if data.get('type') == 'ping':
return
if 'message' in data:
self.handle_price_update(data['message'])
def handle_price_update(self, data):
if data.get('type') == 'price_update':
price_data = data['data']
change_percent = abs(price_data.get('change_24h_percent', 0))
if change_percent > self.alert_threshold:
self.trigger_alert(price_data, change_percent)
def trigger_alert(self, price_data, change_percent):
direction = "š" if price_data.get('change_24h', 0) > 0 else "š"
print(f"šØ PRICE ALERT: {price_data['name']} {direction}")
print(f" Current: ${price_data['price']}")
print(f" Change: {change_percent:.2f}% in 24h")
print(f" Time: {price_data['created_at']}\n")
def on_error(self, ws, error):
print(f"WebSocket error: {error}")
def on_close(self, ws):
print("Price alert connection closed")
def on_open(self, ws):
print("ā
Connected to real-time price alerts")
subscribe_message = {
'command': 'subscribe',
'identifier': json.dumps({
'channel': 'EnergyPricesChannel',
'api_key': self.api_key
})
}
ws.send(json.dumps(subscribe_message))
def start_monitoring(self):
websocket.enableTrace(False)
self.ws = websocket.WebSocketApp(
"wss://api.oilpriceapi.com/cable",
on_message=self.on_message,
on_error=self.on_error,
on_close=self.on_close,
on_open=self.on_open
)
self.ws.run_forever()
alert_system = PriceAlertSystem('YOUR_API_KEY', alert_threshold=2.0)
monitor_thread = threading.Thread(target=alert_system.start_monitoring)
monitor_thread.daemon = True
monitor_thread.start()
print("š Price alert system running...")
print("Will alert on price moves >2%")
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
print("\nā¹ļø Stopping price alerts...")
Note: WebSocket alerts require Reservoir Mastery subscription. For free tiers, use the REST API with reasonable polling intervals to avoid rate limits.
import React, { useState, useEffect } from 'react';
function PriceGrid() {
const [prices, setPrices] = useState([]);
useEffect(() => {
const fetchPrices = async () => {
const response = await fetch('/api/prices/all', {
headers: {
'Authorization': 'Token YOUR_API_KEY'
}
});
const data = await response.json();
setPrices(data.data.prices);
};
fetchPrices();
const interval = setInterval(fetchPrices, 60000);
return () => clearInterval(interval);
}, []);
return (
<div className="price-grid">
{prices.map(commodity => (
<div key={commodity.code} className="price-card">
<h3>{commodity.name}</h3>
<div className="price">${commodity.price}</div>
<div className={commodity.change_24h > 0 ? 'up' : 'down'}>
{commodity.change_24h_percent.toFixed(2)}%
</div>
</div>
))}
</div>
);
}
- Reduced API Calls: Get all data in one request instead of 40+ individual calls
- Lower Latency: Single round-trip for complete market overview
- Synchronized Data: All prices from the same timestamp
- Simplified Code: One endpoint to maintain in your application
- Cost Effective: Counts as single request against your limit
- Response Time: < 200ms average
- Payload Size: ~15KB (compressed)
- Cache Headers: Included for client-side caching
- CDN: Global edge locations for low latency
Status | Description |
---|
401 | Unauthorized - Invalid API key |
429 | Rate limit exceeded |
503 | Service temporarily unavailable |
504 | Gateway timeout - try with filters |
/v1/prices/latest?code={CODE}
- Single commodity price/v1/prices/past_day
- 24-hour historical data/v1/commodities
- List of available commodities/v1/prices/marine-fuels
- Detailed marine fuel prices by port