Skip to content

feat(oilpriceapi): add OilPriceAPI provider with CommoditySpotPrices - #7631

Open
karlwaldman wants to merge 2 commits into
OpenBB-finance:developfrom
karlwaldman:feat/oilpriceapi-provider
Open

feat(oilpriceapi): add OilPriceAPI provider with CommoditySpotPrices#7631
karlwaldman wants to merge 2 commits into
OpenBB-finance:developfrom
karlwaldman:feat/oilpriceapi-provider

Conversation

@karlwaldman

Copy link
Copy Markdown

What

Adds a provider extension for OilPriceAPI, implementing the CommoditySpotPrices standard model behind obb.commodity.price.spot.

That command currently has one provider, fred, serving 12 hardcoded FRED series. OilPriceAPI's public catalogue (GET /v1/commodities) exposes 463 series — crude benchmarks, natural gas, refined products, coal, carbon, marine fuels and drilling activity — each carrying its own source timestamp and freshness metadata.

Behaviour

Query Endpoint
no start_date/end_date /v1/prices/latest — latest observation
either date supplied /v1/prices/historical — daily series

commodity accepts friendly aliases (brent, wti, dutch_ttf, eu_carbon, …) or any raw catalogue code, forwarded unchanged.

from openbb import obb

obb.commodity.price.spot(provider="oilpriceapi", commodity="brent")
obb.commodity.price.spot(provider="oilpriceapi", commodity="wti",
                         start_date="2026-01-01", end_date="2026-06-30")

Design notes

  • Depends only on openbb-core. Uses amake_request rather than adding an HTTP client.
  • The API's error envelope carries code, message and request_id — surfaced rather than swallowed.
  • EmptyDataError distinguishes unknown commodity from valid commodity, empty window; the first message points at /v1/commodities.
  • Registered as an optional provider in dev_install.py, matching the nasdaq/tmx pattern.

Verification

Run against the live API before submission, not just unit-tested:

latest brent          -> 1 row   2026-08-05 BRENT_CRUDE_USD 79.31 barrel USD
wti 2026-07-01..07-31 -> 29 rows 2026-07-01 WTI_USD 68.83 barrel USD
raw code passthrough  -> DUTCH_TTF_EUR 53.44 mwh EUR
unknown commodity     -> EmptyDataError naming /v1/commodities
invalid credential    -> OpenBBError UNAUTHORIZED with request_id
empty date window     -> EmptyDataError reporting records found vs window

Credentials for review

Free tier is 200 requests/month, no card required (https://www.oilpriceapi.com/auth/signup). There is also a keyless demo endpoint if you'd rather not sign up at all:

curl https://api.oilpriceapi.com/v1/demo/prices

Happy to provide a reviewer key — just say where to send it.

Not included

tests/record/ cassettes are not committed: record_http needs to run in your CI environment to capture them against a real key. Glad to add them however you prefer — or I can record with a throwaway key if that's the convention.

Docs: https://docs.oilpriceapi.com · OpenAPI: https://api.oilpriceapi.com/.well-known/openapi.json

Adds a new provider extension for OilPriceAPI (https://www.oilpriceapi.com),
implementing the `CommoditySpotPrices` standard model behind
`obb.commodity.price.spot`.

Today that command has a single provider, `fred`, which serves 12 hardcoded
FRED series at daily-or-slower cadence. OilPriceAPI's public catalogue
(GET /v1/commodities) exposes 463 series — crude benchmarks, natural gas,
refined products, coal, carbon, marine fuels and drilling activity — each
carrying its own source timestamp and freshness metadata.

Behaviour:
- No start_date/end_date -> latest observation via /v1/prices/latest
- Either date supplied  -> daily series via /v1/prices/historical
- `commodity` accepts friendly aliases (brent, wti, dutch_ttf, eu_carbon, ...)
  or any raw catalogue code, forwarded unchanged

Depends only on openbb-core; uses amake_request rather than adding an HTTP
client. Error envelopes from the API carry a code, message and request_id and
are surfaced rather than swallowed. EmptyDataError distinguishes "unknown
commodity" from "valid commodity, empty window".

Verified against the live API before submission:
  latest brent          -> 1 row   2026-08-05 BRENT_CRUDE_USD 79.31 barrel USD
  wti 2026-07-01..07-31 -> 29 rows 2026-07-01 WTI_USD 68.83 barrel USD
  raw code passthrough  -> DUTCH_TTF_EUR 53.44 mwh EUR
  unknown commodity     -> EmptyDataError naming /v1/commodities
  invalid credential    -> OpenBBError UNAUTHORIZED with request_id
  empty date window     -> EmptyDataError reporting records found vs window

Registered as an optional provider in dev_install.py, matching the pattern
used by nasdaq/tmx.

Free tier is 200 requests/month with no card required, and a keyless demo
endpoint (/v1/demo/prices) is available for evaluation without signing up.
…sts, README

The provider implementation itself; the preceding commit registered it in
dev_install.py.

Verified against the live API before submission:
  latest brent          -> 1 row   2026-08-05 BRENT_CRUDE_USD 79.31 barrel USD
  wti 2026-07-01..07-31 -> 29 rows 2026-07-01 WTI_USD 68.83 barrel USD
  raw code passthrough  -> DUTCH_TTF_EUR 53.44 mwh EUR
  unknown commodity     -> EmptyDataError naming /v1/commodities
  invalid credential    -> OpenBBError UNAUTHORIZED with request_id
  empty date window     -> EmptyDataError reporting records found vs window
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants