Skip to content

feat: market-brief + agent-subscription methods (sync+async, v1.9.0)#37

Merged
karlwaldman merged 1 commit into
mainfrom
feat/3245-subscriptions
Jun 21, 2026
Merged

feat: market-brief + agent-subscription methods (sync+async, v1.9.0)#37
karlwaldman merged 1 commit into
mainfrom
feat/3245-subscriptions

Conversation

@karlwaldman

Copy link
Copy Markdown
Member

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)MarketBrief
  • await client.market_brief(...) (async mirror)

Agent subscriptions (client.subscriptions / await client.subscriptions)

  • .list()List[Subscription]
  • .create(codes, interval, name=None, source=None, tool=None)Subscription
    • friendly interval mapping: "5m"/"1h"/"daily" (and "<n>s/m/h/d" / raw int) → interval_seconds
    • X-OPA-Source / X-OPA-Tool attribution headers (default source sdk-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, plus SubscriptionEventsPage.

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, marked live): market_brief(["BRENT_CRUDE_USD"]) returns 200 + a positive price, and subscriptions.list() returns 200. It uses OILPRICEAPI_TEST_KEY and skips automatically when absent (no prod writes in CI by default).

Not executed against production in this run — no OILPRICEAPI_TEST_KEY was 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

Gate Command Result
mypy mypy oilpriceapi/ --ignore-missing-imports ✅ Success, no issues (43 files)
ruff ruff check oilpriceapi/ ✅ All checks passed
pytest pytest tests/ --ignore=tests/integration --ignore=tests/contract -m 'not slow' --cov=oilpriceapi ✅ 311 passed, 9 skipped, cov 59.33% (>50% gate)

🤖 Generated with Claude Code

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>
@coderabbitai

coderabbitai Bot commented Jun 21, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@karlwaldman, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3999e652-138b-4ee9-8112-156d3444a7a0

📥 Commits

Reviewing files that changed from the base of the PR and between 785b385 and d24affe.

📒 Files selected for processing (14)
  • README.md
  • oilpriceapi/__init__.py
  • oilpriceapi/_subscriptions_common.py
  • oilpriceapi/async_client.py
  • oilpriceapi/async_resources.py
  • oilpriceapi/client.py
  • oilpriceapi/models.py
  • oilpriceapi/resources/__init__.py
  • oilpriceapi/resources/subscriptions.py
  • oilpriceapi/version.py
  • pyproject.toml
  • tests/integration/test_live_subscriptions.py
  • tests/unit/test_async_subscriptions_resource.py
  • tests/unit/test_subscriptions_resource.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/3245-subscriptions

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@karlwaldman karlwaldman merged commit 81e24b1 into main Jun 21, 2026
6 checks passed
@karlwaldman karlwaldman deleted the feat/3245-subscriptions branch June 21, 2026 21:14
karlwaldman added a commit that referenced this pull request Jul 3, 2026
…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>
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.

1 participant