OilPriceAPI Documentation
Source-timestamped oil, gas, and related energy data via REST API
Developer Quick Reference
Looking for a fast, searchable API reference? Quick Reference → - All endpoints, commodity codes, and examples in one place. Copy-paste ready.
Reviewed Product Facts
Source-timestamped oil, gas, refined-product, futures, and related energy data delivered through a normalized REST API.
- Offer: The Core commodity API includes a 7-day trial with 10,000 requests and no credit card. After the trial, the Free plan includes 200 requests per month. Dataset access and limits vary by plan, source, and account entitlement.
- Catalog: A broad catalog spanning crude oil, natural gas, refined products, futures, marine fuels, carbon markets, metals, forex, and selected energy-intelligence datasets.
- Freshness: Latest available values include source timestamps; refresh cadence varies by source, market hours, dataset, and plan.
- Authentication:
Authorization: Token YOUR_API_KEY - Environment variable:
OILPRICEAPI_KEY - First request:
GET https://api.oilpriceapi.com/v1/prices/latest?by_code=BRENT_CRUDE_USD - Keyless demo:
https://api.oilpriceapi.com/v1/demo/prices - Data rights: OilPriceAPI sells API access, normalization, monitoring, and delivery. Standard plans do not grant ownership of underlying source data or unrestricted raw-data redistribution rights. Review the Data Usage Policy before public display or redistribution.
Contract version: 2026-07-18 (canonical JSON).
What's New
- June 2026: Well Production Data — four-state launch (TX, AK, NM, ND) with US national rollup
- June 2026: AI-agent endpoints for the MCP server —
market-briefand agentsubscriptions - December 2025: 7-day free trial with 10,000 requests
- October 2025: WebSocket delivery for eligible datasets and accounts
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 "https://api.oilpriceapi.com/v1/prices/latest?by_code=BRENT_CRUDE_USD" \
-H "Authorization: Token YOUR_API_KEY"
import requests
response = requests.get(
"https://api.oilpriceapi.com/v1/prices/latest",
params={"by_code": "BRENT_CRUDE_USD"},
headers={"Authorization": "Token YOUR_API_KEY"}
)
data = response.json()
print(data["data"]["formatted"], data["data"]["created_at"])
const response = await fetch(
"https://api.oilpriceapi.com/v1/prices/latest?by_code=BRENT_CRUDE_USD",
{ headers: { Authorization: "Token YOUR_API_KEY" } },
);
const data = await response.json();
console.log(data.data.formatted, data.data.created_at);
req, _ := http.NewRequest("GET",
"https://api.oilpriceapi.com/v1/prices/latest?by_code=BRENT_CRUDE_USD", nil)
req.Header.Set("Authorization", "Token YOUR_API_KEY")
resp, _ := http.DefaultClient.Do(req)
// Parse response...
Step 3: Response Shape
Values and source labels below are illustrative. Use the returned created_at and source metadata to evaluate freshness for your workflow.
{
"status": "success",
"data": {
"price": 74.52,
"formatted": "$74.52",
"currency": "USD",
"code": "WTI_USD",
"created_at": "2026-07-18T15:30:00.000Z",
"type": "spot_price",
"source": "example_source",
"metadata": {
"source": "example_source"
}
}
}
Common Commodity Codes
| Code | Description | Category |
|---|---|---|
WTI_USD | West Texas Intermediate Crude Oil | Crude Oil |
BRENT_CRUDE_USD | Brent Crude Oil | Crude Oil |
NATURAL_GAS_USD | Henry Hub Natural Gas | Natural Gas |
DIESEL_USD | Ultra Low Sulfur Diesel | Refined Products |
HEATING_OIL_USD | Heating Oil No. 2 | Refined Products |
JET_FUEL_USD | Jet Fuel (Kerosene) | Refined Products |
GASOLINE_USD | RBOB Gasoline | Refined Products |
COAL_USD | Thermal Coal (Newcastle) | Coal |
First Call Troubleshooting
| Error | Cause | Solution |
|---|---|---|
401 Unauthorized | Invalid or missing API key | Check header format: Authorization: Token YOUR_KEY (not Bearer) |
invalid_code (400) | Unknown commodity code in by_code | Use codes from the table above. Codes are case-insensitive. |
429 Too Many Requests | Rate limit exceeded | Read the response limit headers, implement backoff, and verify the current account limit. |
TRIAL_EXPIRED | 7-day trial ended | Continue within the Free plan limit or review current plans →. |
| Connection timeout | Network issue | Retry with exponential backoff. Check API status |
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 |
Documentation
- Quick Reference - Fast, searchable cheat sheet with all codes and endpoints
- 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: support@oilpriceapi.com
- API Status: api.oilpriceapi.com/v1/status