Oil Price API Documentation - Quick Start in 5 Minutes | REST API
GitHub
GitHub

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+)

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=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

CodeDescriptionCategoryUpdate Frequency
WTI_USDWest Texas Intermediate Crude OilCrude OilEvery 5 min
BRENT_CRUDE_USDBrent Crude OilCrude OilEvery 5 min
NATURAL_GAS_USDHenry Hub Natural GasNatural GasEvery 5 min
DIESEL_USDUltra Low Sulfur DieselRefined ProductsEvery 5 min
HEATING_OIL_USDHeating Oil No. 2Refined ProductsEvery 5 min
JET_FUEL_USDJet Fuel (Kerosene)Refined ProductsEvery 5 min
GASOLINE_USDRBOB GasolineRefined ProductsEvery 5 min
COAL_USDThermal Coal (Newcastle)CoalDaily

View all 50+ commodities →


First Call Troubleshooting

ErrorCauseSolution
401 UnauthorizedInvalid or missing API keyCheck header format: Authorization: Token YOUR_KEY (not Bearer)
INVALID_COMMODITYUnknown commodity codeUse codes from table above. Codes are case-insensitive.
429 Too Many RequestsRate limit exceededFree trial: 60 requests/minute. Implement backoff or upgrade →
TRIAL_EXPIRED7-day trial endedUpgrade to a paid plan →
Connection timeoutNetwork issueRetry 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

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

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.

View pricing →


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

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

Integrations

  • Google Sheets
  • Power BI
  • Zapier
  • n8n

Support

  • Email: [email protected]
  • Status: status.oilpriceapi.com
  • Response time: 1-3 business days
Copyright © 2025 OilPriceAPI