Skip to content

[Provider] Add OilPriceAPI provider for commodity prices #7291

@karlwaldman

Description

@karlwaldman

Summary

Request to add OilPriceAPI as a provider for real-time oil and commodity prices.

Provider Details

Supported Data

  • Crude Oil: WTI, Brent, Urals, Dubai
  • Natural Gas: US (Henry Hub), EU (TTF), UK (NBP)
  • Other: Coal, Diesel, Gasoline

Features Implemented

  • OilPrice fetcher - Latest prices for all commodities
  • OilHistorical fetcher - Historical prices (past_day, past_week, past_month)
  • Error handling with retries (exponential backoff for rate limits)
  • 89% test coverage (43 tests)

Why Add This Provider?

  1. Commodity Focus: OpenBB lacks a dedicated commodity price provider
  2. Reliability: Built-in retry logic and comprehensive error handling
  3. Free Tier: Users can get started with a free API key
  4. Well-Documented: Full README with examples and API reference

Implementation

The provider follows OpenBB conventions:

  • Fetcher pattern with transform_query, aextract_data, transform_data
  • Pydantic models for query params and data
  • Symbol mapping between OpenBB and API codes

Usage Example

from openbb import obb

obb.user.credentials.oilpriceapi_api_key = "your_key"

# Get all commodity prices
prices = obb.commodity.oil.price(provider="oilpriceapi")

# Get historical WTI prices
history = obb.commodity.oil.historical(symbol="WTI", period="past_week", provider="oilpriceapi")

I'm happy to submit a PR with the full provider implementation if you're interested in including it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions