🛢️ OilPriceAPI Python SDK

Real-time oil & commodity price data for Python developers

Professional-grade API at 98% less cost than Bloomberg Terminal

pip install oilpriceapi
1,000+
Downloads/Month
20+
Commodities
20
Years of Data

⚡ Real-Time Prices

Latest spot prices for Brent, WTI, Natural Gas, Coal, and more. Updated every 15 minutes.

📊 Historical Data

20+ years of daily price history. Perfect for backtesting, analysis, and forecasting.

🐼 Pandas Integration

Native pandas DataFrame support. Time-series analysis made easy.

⚙️ Type-Safe

Full type hints for autocomplete in your IDE. Catch errors before runtime.

🔄 Async Support

Built-in async client for high-performance applications.

✅ Well-Tested

98% test coverage. Production-ready and reliable.

Quick Start

from oilpriceapi import OilPriceAPI

# Initialize client
client = OilPriceAPI()  # Uses OILPRICEAPI_KEY env var

# Get latest Brent Crude price
brent = client.prices.get("BRENT_CRUDE_USD")
print(f"Brent Crude: ${brent.value:.2f}")
# Output: Brent Crude: $71.45

# Get historical data as pandas DataFrame
df = client.prices.past_year("WTI_USD", as_dataframe=True)
print(df.describe())

# Async support
from oilpriceapi import AsyncOilPriceAPI

async with AsyncOilPriceAPI() as client:
    prices = await client.prices.get_multiple([
        "BRENT_CRUDE_USD",
        "WTI_USD",
        "NATURAL_GAS_USD"
    ])

📚 Documentation

Full API Reference

Code Examples