feat: market-brief + agent-subscription methods (sync+async, v1.9.0)#37
Conversation
Add SDK support for the now-live #3245 endpoints on both the sync and
async clients:
- client.market_brief(codes, narrative=False) -> MarketBrief
- client.subscriptions.list() / .create() / .delete() / .events()
with friendly interval mapping ("5m"/"1h"/"daily" -> interval_seconds)
and X-OPA-Source / X-OPA-Tool attribution headers (default source
"sdk-python"). Mirrored on AsyncOilPriceAPI.
New Pydantic models (MarketBrief, MarketBriefCommodity,
MarketBriefForecast, Subscription, SubscriptionEvent) plus a
SubscriptionEventsPage helper, all exported from the package root.
Tests: mocked sync + async unit tests, interval-mapping coverage, and a
read-only live integration test (marked `live`, skips without
OILPRICEAPI_TEST_KEY, no prod writes).
Version bumped 1.8.1 -> 1.9.0.
Gates: mypy clean, ruff clean, pytest 311 passed (cov 59%).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Warning Review limit reached
More reviews will be available in 48 minutes and 16 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (14)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…37) Add SDK support for the now-live #3245 endpoints on both the sync and async clients: - client.market_brief(codes, narrative=False) -> MarketBrief - client.subscriptions.list() / .create() / .delete() / .events() with friendly interval mapping ("5m"/"1h"/"daily" -> interval_seconds) and X-OPA-Source / X-OPA-Tool attribution headers (default source "sdk-python"). Mirrored on AsyncOilPriceAPI. New Pydantic models (MarketBrief, MarketBriefCommodity, MarketBriefForecast, Subscription, SubscriptionEvent) plus a SubscriptionEventsPage helper, all exported from the package root. Tests: mocked sync + async unit tests, interval-mapping coverage, and a read-only live integration test (marked `live`, skips without OILPRICEAPI_TEST_KEY, no prod writes). Version bumped 1.8.1 -> 1.9.0. Gates: mypy clean, ruff clean, pytest 311 passed (cov 59%). Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds Python SDK support for the now-live #3245 endpoints on both the sync (
OilPriceAPI) and async (AsyncOilPriceAPI) clients.Methods added
Market brief
client.market_brief(codes, narrative=False)→MarketBriefawait client.market_brief(...)(async mirror)Agent subscriptions (
client.subscriptions/await client.subscriptions).list()→List[Subscription].create(codes, interval, name=None, source=None, tool=None)→Subscriptionintervalmapping:"5m"/"1h"/"daily"(and"<n>s/m/h/d"/ raw int) →interval_secondsX-OPA-Source/X-OPA-Toolattribution headers (default sourcesdk-python).delete(id)→bool.events(since=None, limit=None, watch_id=None)→SubscriptionEventsPage(iterable;.events,.cursor,.has_more)Models (exported from package root):
MarketBrief,MarketBriefCommodity,MarketBriefForecast,Subscription,SubscriptionEvent, plusSubscriptionEventsPage.Version bumped 1.8.1 → 1.9.0 (
pyproject.toml+version.py). README updated with sync + async usage examples. No release tag cut.Live-test result
A read-only live integration test was added (
tests/integration/test_live_subscriptions.py, markedlive):market_brief(["BRENT_CRUDE_USD"])returns 200 + a positive price, andsubscriptions.list()returns 200. It usesOILPRICEAPI_TEST_KEYand skips automatically when absent (no prod writes in CI by default).Not executed against production in this run — no
OILPRICEAPI_TEST_KEYwas available in the environment, so the live tests skipped as designed (2 skipped). The mocked unit tests fully exercise the request shapes, interval mapping, attribution headers, and response parsing.Gates
mypy oilpriceapi/ --ignore-missing-importsruff check oilpriceapi/pytest tests/ --ignore=tests/integration --ignore=tests/contract -m 'not slow' --cov=oilpriceapi🤖 Generated with Claude Code