OilPriceAPI Documentation
Real-time oil, gas, and energy commodity price data via REST API
What's New
- December 2025: 7-day free trial with 10,000 requests
- December 2025: New onboarding email sequence for first-time users
- November 2025: Added 8 new coal commodity endpoints
- October 2025: WebSocket streaming for real-time prices (Professional+)
Quick Start
Get your first API response in under 2 minutes.
Step 1: Get Your API Key
Sign up free → Dashboard → Copy API Key
Step 2: Make Your First Request
cURL
curl "https://api.oilpriceapi.com/v1/prices/latest?by_code=WTI_USD" \
-H "Authorization: Token YOUR_API_KEY"
Python
import requests
response = requests.get(
"https://api.oilpriceapi.com/v1/prices/latest",
params={"by_code": "WTI_USD"},
headers={"Authorization": "Token YOUR_API_KEY"}
)
data = response.json()
print(f"WTI Price: {data['data']['formatted']}") # $74.52
JavaScript
const response = await fetch(
"https://api.oilpriceapi.com/v1/prices/latest?by_code=WTI_USD",
{ headers: { "Authorization": "Token YOUR_API_KEY" } }
);
const data = await response.json();
console.log(`WTI Price: ${data.data.formatted}`); // $74.52
Go
req, _ := http.NewRequest("GET",
"https://api.oilpriceapi.com/v1/prices/latest?by_code=WTI_USD", nil)
req.Header.Set("Authorization", "Token YOUR_API_KEY")
resp, _ := http.DefaultClient.Do(req)
// Parse response...
Step 3: Response
{
"status": "success",
"data": {
"price": 74.52,
"formatted": "$74.52",
"currency": "USD",
"code": "WTI_USD",
"created_at": "2025-12-29T15:30:00.000Z",
"type": "spot_price",
"source": "oilprice.business_insider",
"metadata": {
"source": "oilprice.business_insider",
"source_description": "Business Insider - Most accurate source matching ICE exchange prices"
}
}
}
Common Commodity Codes
| Code | Description | Category | Update Frequency |
|---|---|---|---|
WTI_USD | West Texas Intermediate Crude Oil | Crude Oil | Every 5 min |
BRENT_CRUDE_USD | Brent Crude Oil | Crude Oil | Every 5 min |
NATURAL_GAS_USD | Henry Hub Natural Gas | Natural Gas | Every 5 min |
DIESEL_USD | Ultra Low Sulfur Diesel | Refined Products | Every 5 min |
HEATING_OIL_USD | Heating Oil No. 2 | Refined Products | Every 5 min |
JET_FUEL_USD | Jet Fuel (Kerosene) | Refined Products | Every 5 min |
GASOLINE_USD | RBOB Gasoline | Refined Products | Every 5 min |
COAL_USD | Thermal Coal (Newcastle) | Coal | Daily |
First Call Troubleshooting
| Error | Cause | Solution |
|---|---|---|
401 Unauthorized | Invalid or missing API key | Check header format: Authorization: Token YOUR_KEY (not Bearer) |
INVALID_COMMODITY | Unknown commodity code | Use codes from table above. Codes are case-insensitive. |
429 Too Many Requests | Rate limit exceeded | Free trial: 60 requests/minute. Implement backoff or upgrade → |
TRIAL_EXPIRED | 7-day trial ended | Upgrade to a paid plan → |
| Connection timeout | Network issue | Retry with exponential backoff. Check status page |
Base URL
https://api.oilpriceapi.com/v1
Authentication
All requests require an API key in the Authorization header:
Authorization: Token YOUR_API_KEY
See the Authentication Guide for security best practices and code examples.
Core Endpoints
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /prices/latest | Latest commodity prices | Yes |
| GET | /prices/past_day | Hourly prices (24h) | Yes |
| GET | /prices/past_week | Daily prices (7d) | Yes |
| GET | /prices/past_month | Daily prices (30d) | Yes |
| GET | /prices/historical | Custom date range | Yes (Paid) |
| GET | /commodities | List all commodities | Yes |
Free Trial
New accounts get a 7-day free trial with:
- 10,000 API requests during trial period
- Access to all commodities (50+)
- Full API functionality
- No credit card required
After trial, choose a plan starting at $15/month for 10,000 requests.
Documentation
- API Reference - Complete endpoint documentation
- Swagger UI - Interactive API explorer
- Authentication Guide - Security and best practices
- Error Codes - Error handling reference
- Rate Limiting - Usage limits and optimization
- Production Checklist - Go-live preparation
Developer SDKs
Integrations
Support
- Email: [email protected]
- Status: status.oilpriceapi.com
- Response time: 1-3 business days