Skip to main content

openbb-oilpriceapi

PyPI version CI

OpenBB provider fetchers for source-timestamped records from OilPriceAPI. Dataset access depends on the API key's plan, source, and account entitlements.

Install

python -m pip install openbb-oilpriceapi

The package registers the oilpriceapi provider extension and these provider models:

Provider model Fetcher Purpose
OilPrice OilPriceAPIFetcher Latest available price record
OilHistorical OilHistoricalFetcher Versioned historical-period records

These are provider fetchers, not an OpenBB router extension. OpenBB documents direct fetcher execution as the supported way to use a provider independently of a router.

Quickstart

Create or manage a key at the OilPriceAPI signup page, then set it outside your source code:

export OPENBB_OILPRICEAPI_API_KEY="your_key"
python examples/quickstart.py BRENT

The equivalent Python query is:

import asyncio
import os

from openbb_oilpriceapi.models import OilPriceAPIFetcher

prices = asyncio.run(
    OilPriceAPIFetcher.fetch_data(
        {"symbol": "BRENT"},
        {"api_key": os.environ["OPENBB_OILPRICEAPI_API_KEY"]},
    )
)
record = prices[0]
print(record.symbol, record.price, record.currency, record.updated_at, record.source)

For an OpenBB application settings file, the credential name is oilpriceapi_api_key. After installing a provider into an existing OpenBB environment, rebuild its extension map as described in the OpenBB provider documentation.

Symbols

The package deliberately exposes a curated, versioned set of OpenBB-style symbols rather than dynamically importing /commodities. OpenBB query choices must be deterministic, while the API catalog and account entitlements can change independently. A mapping means the provider can construct the request; it does not guarantee that every API key can access that dataset. New mappings are reviewed and shipped in provider releases.

Symbol OilPriceAPI code
WTI WTI_USD
BRENT BRENT_CRUDE_USD
URALS URALS_CRUDE_USD
DUBAI DUBAI_CRUDE_USD
NG NATURAL_GAS_USD
NG_EU DUTCH_TTF_EUR
NG_UK NATURAL_GAS_GBP
COAL COAL_USD
DIESEL_US DIESEL_USD
GASOLINE_US GASOLINE_USD

Omitting symbol from OilPriceAPIFetcher requests the API's default latest record. It does not request the complete catalog.

Historical Query

import asyncio
import os

from openbb_oilpriceapi.models import OilHistoricalFetcher

history = asyncio.run(
    OilHistoricalFetcher.fetch_data(
        {"symbol": "WTI", "period": "past_week"},
        {"api_key": os.environ["OPENBB_OILPRICEAPI_API_KEY"]},
    )
)
for record in history:
    print(record.date, record.price, record.currency, record.unit, record.source)

Supported request values are past_day, past_week, past_month, and past_year. Response timestamps, units, currencies, and source labels are taken from the API response. The provider raises a typed error instead of inventing values when a successful response is empty or malformed.

Error Recovery

The public exception classes are:

  • AuthenticationError: add or replace the configured API key.
  • EntitlementError: review the current pricing and access options.
  • RateLimitError: retry after the account's rate-limit window.
  • ProviderTimeoutError: retry the request later.
  • ResponseSchemaError: preserve the response context and report upstream schema drift.
  • NotFoundError: check the requested symbol mapping.

Product Facts

Do not copy plan limits, catalog totals, source cadence, or redistribution terms from this repository. Those facts change independently of the provider. Use the versioned product-facts contract, API documentation, and data-usage policy when publishing derived material.

Development

poetry install
poetry run pytest -q
poetry build

To run the bounded production smoke (one latest request and one past_year request) with a safe test credential:

OPENBB_OILPRICEAPI_API_KEY="..." poetry run python scripts/live_smoke.py

The smoke prints only the returned symbol and history record count; it never prints the credential or request headers.

License

MIT

Release files for openbb-oilpriceapi 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openbb-oilpriceapi 0.3.0
File Size Uploaded
openbb_oilpriceapi-0.3.0.tar.gz 10.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for openbb-oilpriceapi 0.3.0
File Interpreter ABI Platform
openbb_oilpriceapi-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.8 kB

Release files / openbb_oilpriceapi-0.3.0.tar.gz

Download URL openbb_oilpriceapi-0.3.0.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
0b8f8cf3af2016ff42e3e19ab74094e0deaa63e4f29eb483e22b26747f192296
BLAKE2b-256 checksum
How to use checksums
41d59f57d2497a5a2deb536bedaf12ac5106364f8a1abffa298245dc26d1cb37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.14 Linux/6.17.0-1022-azure

Release files / openbb_oilpriceapi-0.3.0-py3-none-any.whl

Download URL openbb_oilpriceapi-0.3.0-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
769e542adf7747d267a34668c1a8f857f1c2a8d3d7183bb402abb766f3bc8c58
BLAKE2b-256 checksum
How to use checksums
ea52d29bcd10bfaab705a365f05dde92f2b296823fe98b566c984b3c295978a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.14 Linux/6.17.0-1022-azure

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page