API Reference
Authentication
Authorization: Token YOUR_API_KEY
Get your API key from oilpriceapi.com/dashboard.
Base URL
https://api.oilpriceapi.com/v1
Response Format
{
"status": "success|error",
"data": { ... },
"meta": {
"request_id": "req_abc123",
"response_time_ms": 42,
"timestamp": "2025-07-18T10:30:00Z"
}
}
Rate Limits
| Plan | Request Quota | Request Rate Limit |
|---|---|---|
| Free | 50 / day | 60 per 60s window |
| Free Trial (7 days) | 10,000 | 60 per 60s window |
| Developer | 10,000 / month | 60 per 60s window |
| Starter | 50,000 / month | 60 per 60s window |
| Professional | 250,000 / month | 60 per 60s window |
| Scale | 1,000,000 / month | 60 per 60s window |
Current tier limits are machine-readable at GET https://api.oilpriceapi.com/v1/meta/limits (no key required); this table is rendered from it at build time. Read limits from the endpoint rather than hardcoding them.
Headers:
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 999
X-RateLimit-Reset: 1736784000
Endpoints
Prices
| Method | Endpoint | Description |
|---|---|---|
| GET | /prices/latest | Latest commodity prices |
| GET | /prices/past_day | Collected points, last 24 hours (paid plan or trial) |
| GET | /prices/past_week | Collected points, last 7 days (paid plan or trial) |
| GET | /prices/past_month | Collected points, last 30 days (paid plan or trial) |
| GET | /prices/past_year | Daily values, last 365 days (paid plan or trial) |
| GET | /prices/historical | Custom date range (paid plan or trial) |
Commodities
| Method | Endpoint | Description |
|---|---|---|
| GET | /commodities | List all commodities |
| GET | /commodities/{code} | Commodity details |
AI Agents (MCP)
| Method | Endpoint | Description |
|---|---|---|
| GET | /market-brief | Multi-commodity snapshot + forecasts (+ optional narrative) |
| GET | /subscriptions | List recurring watches |
| POST | /subscriptions | Create a recurring watch |
| DELETE | /subscriptions/{id} | Delete a watch |
| GET | /subscriptions/events | Poll for new events (no quota cost) |
See the Agent Subscriptions with MCP recipe for the full agent workflow.
Premium Endpoints
See Premium Features and Plan Requirements for a plan-by-plan matrix and upgrade guidance.
| Method | Endpoint | Description | Plan |
|---|---|---|---|
| GET | /prices/all | Account-available catalog | Professional+ |
| GET | /storage/cushing | Cushing storage data | Professional+ |
| GET | /drilling-intelligence/latest | Drilling intelligence | Scale |
| GET | /futures/ice-brent | ICE Brent futures | Professional+ |
Marine Fuels
| Method | Endpoint | Description |
|---|---|---|
| GET | /marine-ports | List fuel ports |
| GET | /marine-ports/{code} | Port details |
| GET | /prices/marine-fuels | All marine fuel prices |
| GET | /prices/marine-fuels/latest | Latest marine fuel prices, filterable; no API key needed |
| GET | /prices/marine-fuels/historical | Marine fuel price history (paid plan or trial) |
Fuel Surcharges
| Method | Endpoint | Description |
|---|---|---|
| GET | /fuel-surcharge | Latest LTL carrier surcharges |
| GET | /fuel-surcharge/{carrier}/latest | Latest surcharge for one LTL carrier |
| GET | /fuel-surcharge/{carrier}/history | Historical LTL surcharge rows |
| GET | /fuel-surcharge/parcel | Latest parcel surcharges by carrier |
| GET | /fuel-surcharge/parcel/{carrier}/latest | Latest parcel surcharge by service level |
| GET | /fuel-surcharge/parcel/{carrier}/history | Historical parcel surcharge rows |
Common Parameters
| Parameter | Type | Description | Example |
|---|---|---|---|
by_code | string | Commodity code(s), comma-separated. On /prices endpoints a repeated by_code=A&by_code=B is treated as by_code=A,B | WTI_USD,BRENT_CRUDE_USD |
currency | string | Convert supported price responses to USD, EUR, or GBP | EUR |
page | integer | Pagination page number | 1 |
per_page | integer | Results per page (default: 100) | 100 |
See Currency Conversion for endpoint coverage and example responses.
Error Codes
Error shapes vary by status code (see the Error Codes Guide for full JSON bodies):
| Status | Body code | Description |
|---|---|---|
| 401 | UNAUTHORIZED | Missing or invalid API key (error.code) |
| 400 | invalid_code | Unknown commodity code (data.error, with invalid_codes[]) |
| 404 | NOT_FOUND | Unknown route (error.code); check the path and the /v1 prefix |
| 429 | (rate-limit) | Per-minute rate limit exceeded (RATE_LIMIT_EXCEEDED) — back off and retry; an active trial that has used its allowance also gets 429 (TRIAL_LIMIT_EXCEEDED), so branch on error_code |
| 402 | (quota) | Free-tier daily quota exhausted (PAYMENT_REQUIRED), or a paid plan's monthly quota exhausted (MONTHLY_QUOTA_EXCEEDED) — check reset.date or plan |
See the Error Codes Guide for complete request/response examples.
Interactive API Explorer
- Swagger UI - Full interactive API explorer with "Try it" functionality
- API Explorer - Test endpoints directly