Skip to content

Commit 57232ac

Browse files
karlwaldmanclaude
andcommitted
feat: v1.7.0 — World-class SDK upgrade
Major improvements: - Full async client: all 16 resources now available on AsyncOilPriceAPI (was 2) - Add 429 auto-retry with Retry-After header support (capped at 60s) - Add webhook signature verification (verify_signature + standalone export) - Add oilprice CLI tool (price, historical, commodities commands with --json) - Add opt-in telemetry (enable_telemetry=False default) on both sync and async clients - Add async iter_pages() generator for memory-efficient pagination - Add mkdocs + mkdocstrings API reference documentation - Fix version triple mismatch (single source in version.py) - Fix Python 3.8 syntax compatibility (from __future__ import annotations) - Fix await response.json() bug in async client (httpx .json() is synchronous) - Remove unused aiohttp dependency from [async] extra - Export ValidationError, TimeoutError, ConfigurationError from __init__.py - Fix get_current_price() connection leak (now uses context manager) - Sanitize resource IDs from telemetry paths for privacy - Extract shared validators to resource_validators.py (reduce async duplication) - Make lint/mypy blocking in CI (removed continue-on-error) - Add coverage enforcement gate (--cov-fail-under=50) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4cb37f4 commit 57232ac

22 files changed

Lines changed: 2073 additions & 34 deletions

.github/workflows/github-pages.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,26 @@ jobs:
2525
- name: Checkout
2626
uses: actions/checkout@v4
2727

28+
- name: Set up Python
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: "3.12"
32+
33+
- name: Install dependencies
34+
run: |
35+
pip install -e '.[dev]'
36+
pip install mkdocs-material mkdocstrings[python]
37+
38+
- name: Build docs
39+
run: mkdocs build
40+
2841
- name: Setup Pages
2942
uses: actions/configure-pages@v4
3043

3144
- name: Upload artifact
3245
uses: actions/upload-pages-artifact@v3
3346
with:
34-
path: './docs'
47+
path: "./site"
3548

3649
- name: Deploy to GitHub Pages
3750
id: deployment

.github/workflows/test.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,9 @@ jobs:
3030
3131
- name: Lint source with ruff
3232
run: ruff check oilpriceapi/
33-
continue-on-error: true
3433

3534
- name: Type check with mypy
3635
run: mypy oilpriceapi/ --ignore-missing-imports
37-
continue-on-error: true
3836

3937
- name: Run unit tests
4038
run: pytest tests/ --ignore=tests/integration --ignore=tests/contract -m 'not slow' --cov=oilpriceapi --cov-report=xml -v

docs/reference/async_client.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Async Client
2+
3+
::: oilpriceapi.async_client.AsyncOilPriceAPI

docs/reference/client.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Client
2+
3+
::: oilpriceapi.client.OilPriceAPI

docs/reference/exceptions.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Exceptions
2+
3+
::: oilpriceapi.exceptions

docs/reference/models.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Models
2+
3+
::: oilpriceapi.models

docs/reference/resources.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Resources
2+
3+
## Prices
4+
5+
::: oilpriceapi.resources.prices.PricesResource
6+
7+
## Historical
8+
9+
::: oilpriceapi.resources.historical.HistoricalResource
10+
11+
## Diesel
12+
13+
::: oilpriceapi.resources.diesel.DieselResource
14+
15+
## Alerts
16+
17+
::: oilpriceapi.resources.alerts.AlertsResource
18+
19+
## Commodities
20+
21+
::: oilpriceapi.resources.commodities.CommoditiesResource
22+
23+
## Futures
24+
25+
::: oilpriceapi.resources.futures.FuturesResource
26+
27+
## Storage
28+
29+
::: oilpriceapi.resources.storage.StorageResource
30+
31+
## Rig Counts
32+
33+
::: oilpriceapi.resources.rig_counts.RigCountsResource
34+
35+
## Bunker Fuels
36+
37+
::: oilpriceapi.resources.bunker_fuels.BunkerFuelsResource
38+
39+
## Analytics
40+
41+
::: oilpriceapi.resources.analytics.AnalyticsResource
42+
43+
## Forecasts
44+
45+
::: oilpriceapi.resources.forecasts.ForecastsResource
46+
47+
## Data Quality
48+
49+
::: oilpriceapi.resources.data_quality.DataQualityResource
50+
51+
## Drilling Intelligence
52+
53+
::: oilpriceapi.resources.drilling.DrillingIntelligenceResource
54+
55+
## Webhooks
56+
57+
::: oilpriceapi.resources.webhooks.WebhooksResource
58+
59+
## Data Sources
60+
61+
::: oilpriceapi.resources.data_sources.DataSourcesResource

mkdocs.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
site_name: OilPriceAPI Python SDK
2+
site_description: Official Python SDK for OilPriceAPI
3+
site_url: https://oilpriceapi.github.io/python-sdk/
4+
repo_url: https://github.com/oilpriceapi/python-sdk
5+
repo_name: oilpriceapi/python-sdk
6+
7+
theme:
8+
name: material
9+
palette:
10+
scheme: slate
11+
primary: deep orange
12+
features:
13+
- content.code.copy
14+
- navigation.sections
15+
16+
nav:
17+
- Home: index.md
18+
- API Reference:
19+
- Client: reference/client.md
20+
- Async Client: reference/async_client.md
21+
- Resources: reference/resources.md
22+
- Models: reference/models.md
23+
- Exceptions: reference/exceptions.md
24+
25+
plugins:
26+
- search
27+
- mkdocstrings:
28+
handlers:
29+
python:
30+
options:
31+
show_source: false
32+
show_root_heading: true
33+
heading_level: 2
34+
members_order: source
35+
36+
markdown_extensions:
37+
- pymdownx.highlight
38+
- pymdownx.superfences
39+
- admonition

oilpriceapi/__init__.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
The official Python SDK for OilPriceAPI - Real-time and historical oil prices.
55
"""
66

7-
__version__ = "1.5.0"
7+
from oilpriceapi.version import __version__
8+
89
__author__ = "OilPriceAPI"
910
__email__ = "support@oilpriceapi.com"
1011

@@ -16,6 +17,9 @@
1617
RateLimitError,
1718
DataNotFoundError,
1819
ServerError,
20+
ValidationError,
21+
TimeoutError,
22+
ConfigurationError,
1923
)
2024
from oilpriceapi.models import (
2125
DieselPrice,
@@ -34,6 +38,9 @@
3438
"RateLimitError",
3539
"DataNotFoundError",
3640
"ServerError",
41+
"ValidationError",
42+
"TimeoutError",
43+
"ConfigurationError",
3744
"DieselPrice",
3845
"DieselStation",
3946
"DieselStationsResponse",
@@ -42,6 +49,12 @@
4249
"DataConnectorPrice",
4350
]
4451

52+
from oilpriceapi.resources.webhooks import WebhooksResource
53+
54+
# Standalone webhook signature verification
55+
verify_webhook_signature = WebhooksResource.verify_signature
56+
57+
4558
# Convenience function for quick access
4659
def get_current_price(commodity: str, api_key: str = None) -> float:
4760
"""
@@ -59,6 +72,6 @@ def get_current_price(commodity: str, api_key: str = None) -> float:
5972
>>> price = opa.get_current_price("BRENT_CRUDE_USD")
6073
>>> print(f"Oil: ${price}")
6174
"""
62-
client = OilPriceAPI(api_key=api_key)
63-
price = client.prices.get(commodity)
64-
return price.value
75+
with OilPriceAPI(api_key=api_key) as client:
76+
price = client.prices.get(commodity)
77+
return price.value

0 commit comments

Comments
 (0)