OilPriceAPI Docs
GitHub
GitHub

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-brief and agent subscriptions
  • December 2025: 7-day free trial with 10,000 requests
  • October 2025: WebSocket delivery for eligible datasets and accounts

View full changelog →


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=BRENT_CRUDE_USD" \
  -H "Authorization: Token YOUR_API_KEY"
Python
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"])
JavaScript
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);
Go
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

CodeDescriptionCategory
WTI_USDWest Texas Intermediate Crude OilCrude Oil
BRENT_CRUDE_USDBrent Crude OilCrude Oil
NATURAL_GAS_USDHenry Hub Natural GasNatural Gas
DIESEL_USDUltra Low Sulfur DieselRefined Products
HEATING_OIL_USDHeating Oil No. 2Refined Products
JET_FUEL_USDJet Fuel (Kerosene)Refined Products
GASOLINE_USDRBOB GasolineRefined Products
COAL_USDThermal Coal (Newcastle)Coal

Browse the current catalog →


First Call Troubleshooting

ErrorCauseSolution
401 UnauthorizedInvalid or missing API keyCheck header format: Authorization: Token YOUR_KEY (not Bearer)
invalid_code (400)Unknown commodity code in by_codeUse codes from the table above. Codes are case-insensitive.
429 Too Many RequestsRate limit exceededRead the response limit headers, implement backoff, and verify the current account limit.
TRIAL_EXPIRED7-day trial endedContinue within the Free plan limit or review current plans →.
Connection timeoutNetwork issueRetry 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

MethodEndpointDescriptionAuth Required
GET/prices/latestLatest commodity pricesYes
GET/prices/past_dayHourly prices (24h)Yes
GET/prices/past_weekDaily prices (7d)Yes
GET/prices/past_monthDaily prices (30d)Yes
GET/prices/historicalCustom date rangeYes (Paid)
GET/commoditiesList all commoditiesYes

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

  • Python Guide
  • JavaScript Guide
  • Go Guide
  • Ruby Guide
  • C# Guide

Integrations

  • Google Sheets
  • Power BI
  • Zapier
  • n8n

Support

  • Email: support@oilpriceapi.com
  • API Status: api.oilpriceapi.com/v1/status
Copyright © 2025 OilPriceAPI