oilpriceapi 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,11 @@
1
+ # OilPriceAPI Configuration
2
+ # Copy this file to .env and add your actual values
3
+
4
+ # Your OilPriceAPI key (required)
5
+ # Get your free API key at: https://oilpriceapi.com
6
+ OILPRICEAPI_KEY=your_api_key_here
7
+
8
+ # API Base URL (optional)
9
+ # Default: https://api.oilpriceapi.com
10
+ # For local development: http://localhost:5000
11
+ OILPRICEAPI_BASE_URL=https://api.oilpriceapi.com
@@ -0,0 +1,99 @@
1
+ # Changelog
2
+
3
+ All notable changes to the OilPriceAPI Python SDK will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.0.0] - 2025-09-29
9
+
10
+ ### Added
11
+ - ๐ŸŽ‰ Initial release of OilPriceAPI Python SDK
12
+ - โœ… Synchronous client (`OilPriceAPI`)
13
+ - โœ… Asynchronous client (`AsyncOilPriceAPI`)
14
+ - โœ… Type-safe models with Pydantic
15
+ - โœ… Current price operations (`client.prices.get()`)
16
+ - โœ… Historical data operations (`client.historical.get()`)
17
+ - โœ… Pandas DataFrame integration (`to_dataframe()`)
18
+ - โœ… Visualization module with Tufte-style charts
19
+ - โœ… Automatic retry logic with exponential backoff
20
+ - โœ… Rate limit handling
21
+ - โœ… Comprehensive error handling
22
+ - โœ… Context manager support (`with` statements)
23
+ - โœ… Environment variable configuration
24
+ - โœ… Full type hints for IDE autocomplete
25
+ - โœ… Documentation and examples
26
+
27
+ ### Features
28
+ - **Current Prices**: Get latest commodity prices
29
+ - **Historical Data**: Fetch past prices with flexible date ranges
30
+ - **Multi-commodity**: Support for Brent, WTI, Natural Gas, and more
31
+ - **Pagination**: Automatic handling of large datasets
32
+ - **Data Export**: Convert to pandas DataFrames for analysis
33
+ - **Async Support**: High-performance async/await operations
34
+ - **Visualization**: Built-in charting with matplotlib
35
+ - **Type Safety**: Full Pydantic validation
36
+
37
+ ### Security
38
+ - Environment variable-based API key management
39
+ - No hardcoded credentials
40
+ - HTTPS-only communication
41
+ - Safe error messages that don't leak secrets
42
+
43
+ ### Documentation
44
+ - Comprehensive README with examples
45
+ - API reference documentation
46
+ - Security policy (SECURITY.md)
47
+ - Contributing guidelines (CONTRIBUTING.md)
48
+ - Example scripts and notebooks
49
+
50
+ ### Supported Python Versions
51
+ - Python 3.8+
52
+ - Python 3.9
53
+ - Python 3.10
54
+ - Python 3.11
55
+ - Python 3.12
56
+
57
+ ---
58
+
59
+ ## [Unreleased]
60
+
61
+ ### Planned
62
+ - CLI tool (`oilprice` command)
63
+ - WebSocket support for real-time prices
64
+ - Advanced caching with Redis
65
+ - Technical indicators (RSI, MACD, Bollinger Bands)
66
+ - More visualization styles
67
+ - Jupyter notebook widgets
68
+
69
+ ---
70
+
71
+ ## Release Notes
72
+
73
+ ### How to Upgrade
74
+
75
+ ```bash
76
+ # From PyPI
77
+ pip install --upgrade oilpriceapi
78
+
79
+ # From source
80
+ pip install -e ".[dev]"
81
+ ```
82
+
83
+ ### Breaking Changes
84
+ None - this is the initial release.
85
+
86
+ ### Deprecations
87
+ None.
88
+
89
+ ### Migration Guide
90
+ N/A for initial release.
91
+
92
+ ---
93
+
94
+ ## Links
95
+ - [PyPI Package](https://pypi.org/project/oilpriceapi/)
96
+ - [GitHub Repository](https://github.com/oilpriceapi/python-sdk)
97
+ - [Documentation](https://docs.oilpriceapi.com/sdk/python)
98
+ - [API Documentation](https://docs.oilpriceapi.com)
99
+ - [Website](https://oilpriceapi.com)
@@ -0,0 +1,255 @@
1
+ # Contributing to OilPriceAPI Python SDK
2
+
3
+ Thank you for your interest in contributing! We welcome contributions from the community.
4
+
5
+ ## ๐Ÿš€ Quick Start
6
+
7
+ ```bash
8
+ # Clone the repository
9
+ git clone https://github.com/oilpriceapi/python-sdk
10
+ cd python-sdk
11
+
12
+ # Create virtual environment
13
+ python -m venv venv
14
+ source venv/bin/activate # On Windows: venv\Scripts\activate
15
+
16
+ # Install in development mode with all dependencies
17
+ pip install -e ".[dev]"
18
+
19
+ # Set up your API key
20
+ cp .env.example .env
21
+ # Edit .env and add your OILPRICEAPI_KEY
22
+
23
+ # Run tests
24
+ pytest
25
+
26
+ # Format code
27
+ black .
28
+
29
+ # Type checking
30
+ mypy oilpriceapi
31
+ ```
32
+
33
+ ## ๐Ÿ“‹ Ways to Contribute
34
+
35
+ ### 1. Report Bugs
36
+
37
+ Found a bug? Please create an issue with:
38
+ - Clear title and description
39
+ - Steps to reproduce
40
+ - Expected vs actual behavior
41
+ - Python version and OS
42
+ - Code sample if applicable
43
+
44
+ ### 2. Suggest Features
45
+
46
+ Have an idea? Open an issue tagged with `enhancement`:
47
+ - Describe the use case
48
+ - Explain why it's useful
49
+ - Provide examples if possible
50
+
51
+ ### 3. Submit Pull Requests
52
+
53
+ 1. **Fork the repository**
54
+ 2. **Create a feature branch**: `git checkout -b feature/amazing-feature`
55
+ 3. **Make your changes**
56
+ 4. **Add tests** for new functionality
57
+ 5. **Update documentation**
58
+ 6. **Run tests and linting**
59
+ 7. **Commit with clear messages**
60
+ 8. **Push and create a Pull Request**
61
+
62
+ ## ๐Ÿงช Development Workflow
63
+
64
+ ### Running Tests
65
+
66
+ ```bash
67
+ # All tests
68
+ pytest
69
+
70
+ # With coverage
71
+ pytest --cov=oilpriceapi --cov-report=html
72
+
73
+ # Specific test file
74
+ pytest tests/test_client.py
75
+
76
+ # Specific test
77
+ pytest tests/test_client.py::test_get_price
78
+ ```
79
+
80
+ ### Code Quality
81
+
82
+ ```bash
83
+ # Format code
84
+ black oilpriceapi tests
85
+
86
+ # Lint
87
+ ruff check oilpriceapi tests
88
+
89
+ # Type check
90
+ mypy oilpriceapi
91
+
92
+ # Run all checks
93
+ pre-commit run --all-files
94
+ ```
95
+
96
+ ### Testing with Local API
97
+
98
+ ```bash
99
+ # Set environment variables
100
+ export OILPRICEAPI_KEY="your_test_key"
101
+ export OILPRICEAPI_BASE_URL="http://localhost:5000"
102
+
103
+ # Run live tests
104
+ python test_sdk_live.py
105
+ ```
106
+
107
+ ## ๐Ÿ“ Code Style
108
+
109
+ ### Python Style Guide
110
+
111
+ We follow [PEP 8](https://pep8.org/) with these specifics:
112
+ - **Line length**: 100 characters
113
+ - **Formatter**: Black
114
+ - **Linter**: Ruff
115
+ - **Type hints**: Required for all public APIs
116
+ - **Docstrings**: Google style
117
+
118
+ ### Example
119
+
120
+ ```python
121
+ from typing import Optional
122
+
123
+ def get_price(commodity: str, date: Optional[str] = None) -> float:
124
+ """Get commodity price.
125
+
126
+ Args:
127
+ commodity: Commodity code (e.g., "BRENT_CRUDE_USD")
128
+ date: Optional date in YYYY-MM-DD format
129
+
130
+ Returns:
131
+ Price as float
132
+
133
+ Raises:
134
+ DataNotFoundError: If commodity not found
135
+
136
+ Example:
137
+ >>> price = get_price("BRENT_CRUDE_USD")
138
+ >>> print(f"Oil: ${price:.2f}")
139
+ """
140
+ # Implementation
141
+ pass
142
+ ```
143
+
144
+ ## ๐Ÿ”’ Security Guidelines
145
+
146
+ ### Never Commit Secrets
147
+
148
+ - โŒ API keys in code
149
+ - โŒ Passwords or tokens
150
+ - โŒ Environment files (`.env`)
151
+ - โœ… Use environment variables
152
+ - โœ… Use `.env.example` templates
153
+
154
+ ### Security Checklist
155
+
156
+ Before committing:
157
+ - [ ] No hardcoded credentials
158
+ - [ ] Added `.env` to `.gitignore`
159
+ - [ ] Sensitive data in environment variables
160
+ - [ ] Error messages don't leak secrets
161
+ - [ ] Input validation added
162
+
163
+ ## ๐Ÿ“ Documentation
164
+
165
+ ### Docstrings Required For:
166
+ - All public classes
167
+ - All public methods/functions
168
+ - Complex private functions
169
+
170
+ ### Update Documentation When:
171
+ - Adding new features
172
+ - Changing APIs
173
+ - Fixing bugs that affect usage
174
+ - Adding examples
175
+
176
+ ## ๐Ÿงฉ Pull Request Process
177
+
178
+ ### PR Checklist
179
+
180
+ - [ ] Tests pass locally
181
+ - [ ] New tests added for new features
182
+ - [ ] Code formatted with Black
183
+ - [ ] Type hints added
184
+ - [ ] Docstrings updated
185
+ - [ ] CHANGELOG.md updated
186
+ - [ ] No merge conflicts
187
+ - [ ] PR description explains changes
188
+
189
+ ### PR Title Format
190
+
191
+ Use conventional commits:
192
+ - `feat: add WebSocket support`
193
+ - `fix: handle rate limit headers correctly`
194
+ - `docs: update installation instructions`
195
+ - `test: add integration tests for historical data`
196
+ - `refactor: simplify error handling`
197
+ - `chore: update dependencies`
198
+
199
+ ### Review Process
200
+
201
+ 1. Automated tests run on GitHub Actions
202
+ 2. Code review by maintainers
203
+ 3. Address feedback
204
+ 4. Approval and merge
205
+
206
+ ## ๐ŸŽฏ Development Priorities
207
+
208
+ ### High Priority
209
+ - Bug fixes
210
+ - Security improvements
211
+ - Documentation improvements
212
+ - Test coverage
213
+
214
+ ### Medium Priority
215
+ - New features (with issue discussion)
216
+ - Performance optimizations
217
+ - Examples and tutorials
218
+
219
+ ### Low Priority
220
+ - Code style refactoring
221
+ - Minor optimizations
222
+
223
+ ## ๐Ÿค Community Guidelines
224
+
225
+ ### Be Respectful
226
+ - Assume good intentions
227
+ - Be constructive in feedback
228
+ - Help newcomers
229
+ - Focus on the code, not the person
230
+
231
+ ### Be Collaborative
232
+ - Share knowledge
233
+ - Ask questions
234
+ - Document solutions
235
+ - Give credit
236
+
237
+ ## ๐Ÿ“ž Getting Help
238
+
239
+ - **Questions**: Open a GitHub Discussion
240
+ - **Bugs**: Create an issue
241
+ - **Security**: Email security@oilpriceapi.com
242
+ - **General**: support@oilpriceapi.com
243
+
244
+ ## ๐Ÿ“œ License
245
+
246
+ By contributing, you agree that your contributions will be licensed under the MIT License.
247
+
248
+ ## ๐ŸŽ‰ Recognition
249
+
250
+ Contributors will be:
251
+ - Listed in CHANGELOG.md
252
+ - Mentioned in release notes
253
+ - Added to GitHub contributors
254
+
255
+ Thank you for contributing to OilPriceAPI! ๐Ÿ™
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 OilPriceAPI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,28 @@
1
+ # Include documentation
2
+ include README.md
3
+ include LICENSE
4
+ include CHANGELOG.md
5
+ include CONTRIBUTING.md
6
+ include SECURITY.md
7
+
8
+ # Include configuration
9
+ include pyproject.toml
10
+ include .env.example
11
+
12
+ # Include type information
13
+ recursive-include oilpriceapi py.typed
14
+
15
+ # Exclude unnecessary files
16
+ global-exclude *.pyc
17
+ global-exclude *.pyo
18
+ global-exclude __pycache__
19
+ global-exclude .DS_Store
20
+ global-exclude *.so
21
+
22
+ # Exclude test and development files
23
+ exclude test_sdk_live.py
24
+ exclude generate_*.py
25
+ exclude data_validation_comparison.py
26
+ prune tests
27
+ prune docs/_build
28
+ prune htmlcov
@@ -0,0 +1,295 @@
1
+ Metadata-Version: 2.4
2
+ Name: oilpriceapi
3
+ Version: 1.0.0
4
+ Summary: Official Python SDK for OilPriceAPI - Real-time and historical oil prices
5
+ Author-email: OilPriceAPI <support@oilpriceapi.com>
6
+ Maintainer-email: OilPriceAPI Team <support@oilpriceapi.com>
7
+ License: MIT License
8
+
9
+ Copyright (c) 2025 OilPriceAPI
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+ Project-URL: Homepage, https://oilpriceapi.com
29
+ Project-URL: Documentation, https://docs.oilpriceapi.com/sdk/python
30
+ Project-URL: Repository, https://github.com/oilpriceapi/python-sdk
31
+ Project-URL: Issues, https://github.com/oilpriceapi/python-sdk/issues
32
+ Project-URL: Changelog, https://github.com/oilpriceapi/python-sdk/blob/main/CHANGELOG.md
33
+ Keywords: oil,prices,api,commodities,energy,brent,wti,natural gas,trading,finance
34
+ Classifier: Development Status :: 5 - Production/Stable
35
+ Classifier: Intended Audience :: Developers
36
+ Classifier: Intended Audience :: Financial and Insurance Industry
37
+ Classifier: Intended Audience :: Science/Research
38
+ Classifier: License :: OSI Approved :: MIT License
39
+ Classifier: Operating System :: OS Independent
40
+ Classifier: Programming Language :: Python
41
+ Classifier: Programming Language :: Python :: 3
42
+ Classifier: Programming Language :: Python :: 3.8
43
+ Classifier: Programming Language :: Python :: 3.9
44
+ Classifier: Programming Language :: Python :: 3.10
45
+ Classifier: Programming Language :: Python :: 3.11
46
+ Classifier: Programming Language :: Python :: 3.12
47
+ Classifier: Topic :: Office/Business :: Financial
48
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
49
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
50
+ Classifier: Typing :: Typed
51
+ Requires-Python: >=3.8
52
+ Description-Content-Type: text/markdown
53
+ License-File: LICENSE
54
+ Requires-Dist: httpx>=0.24.0
55
+ Requires-Dist: pydantic>=2.0.0
56
+ Requires-Dist: python-dateutil>=2.8.0
57
+ Requires-Dist: typing-extensions>=4.5.0; python_version < "3.10"
58
+ Provides-Extra: pandas
59
+ Requires-Dist: pandas>=1.5.0; extra == "pandas"
60
+ Requires-Dist: numpy>=1.20.0; extra == "pandas"
61
+ Provides-Extra: async
62
+ Requires-Dist: aiohttp>=3.8.0; extra == "async"
63
+ Provides-Extra: cache
64
+ Requires-Dist: redis>=4.5.0; extra == "cache"
65
+ Requires-Dist: cachetools>=5.3.0; extra == "cache"
66
+ Provides-Extra: cli
67
+ Requires-Dist: click>=8.0.0; extra == "cli"
68
+ Requires-Dist: rich>=13.0.0; extra == "cli"
69
+ Provides-Extra: all
70
+ Requires-Dist: oilpriceapi[async,cache,cli,pandas]; extra == "all"
71
+ Provides-Extra: dev
72
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
73
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
74
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
75
+ Requires-Dist: black>=23.0.0; extra == "dev"
76
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
77
+ Requires-Dist: ruff>=0.0.261; extra == "dev"
78
+ Requires-Dist: pre-commit>=3.0.0; extra == "dev"
79
+ Dynamic: license-file
80
+
81
+ # OilPriceAPI Python SDK
82
+
83
+ [![PyPI version](https://badge.fury.io/py/oilpriceapi.svg)](https://badge.fury.io/py/oilpriceapi)
84
+ [![Python](https://img.shields.io/pypi/pyversions/oilpriceapi.svg)](https://pypi.org/project/oilpriceapi/)
85
+ [![Tests](https://github.com/oilpriceapi/python-sdk/actions/workflows/test.yml/badge.svg)](https://github.com/oilpriceapi/python-sdk/actions/workflows/test.yml)
86
+ [![Coverage](https://codecov.io/gh/oilpriceapi/python-sdk/branch/main/graph/badge.svg)](https://codecov.io/gh/oilpriceapi/python-sdk)
87
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
88
+
89
+ The official Python SDK for [OilPriceAPI](https://oilpriceapi.com) - Real-time and historical oil prices for Brent Crude, WTI, Natural Gas, and more.
90
+
91
+ ## ๐Ÿš€ Quick Start
92
+
93
+ ### Installation
94
+
95
+ ```bash
96
+ pip install oilpriceapi
97
+ ```
98
+
99
+ ### Basic Usage
100
+
101
+ ```python
102
+ from oilpriceapi import OilPriceAPI
103
+
104
+ # Initialize client (uses OILPRICEAPI_KEY env var by default)
105
+ client = OilPriceAPI()
106
+
107
+ # Get latest Brent Crude price
108
+ brent = client.prices.get("BRENT_CRUDE_USD")
109
+ print(f"Brent Crude: ${brent.value:.2f}")
110
+ # Output: Brent Crude: $71.45
111
+
112
+ # Get multiple prices
113
+ prices = client.prices.get_multiple(["BRENT_CRUDE_USD", "WTI_USD", "NATURAL_GAS_USD"])
114
+ for price in prices:
115
+ print(f"{price.commodity}: ${price.value:.2f}")
116
+ ```
117
+
118
+ ### Historical Data with Pandas
119
+
120
+ ```python
121
+ # Get historical data as DataFrame
122
+ df = client.prices.to_dataframe(
123
+ commodity="BRENT_CRUDE_USD",
124
+ start="2024-01-01",
125
+ end="2024-12-31",
126
+ interval="daily"
127
+ )
128
+
129
+ # Add technical indicators
130
+ df = client.analysis.with_indicators(
131
+ df,
132
+ indicators=["sma_20", "sma_50", "rsi", "bollinger_bands"]
133
+ )
134
+
135
+ # Calculate spread between Brent and WTI
136
+ spread = client.analysis.spread("BRENT_CRUDE_USD", "WTI_USD", start="2024-01-01")
137
+ ```
138
+
139
+ ## ๐Ÿ“Š Features
140
+
141
+ - โœ… **Simple API** - Intuitive methods for all endpoints
142
+ - โœ… **Type Safe** - Full type hints for IDE autocomplete
143
+ - โœ… **Pandas Integration** - First-class DataFrame support
144
+ - โœ… **Async Support** - High-performance async client
145
+ - โœ… **Smart Caching** - Reduce API calls automatically
146
+ - โœ… **Rate Limit Handling** - Automatic retries with backoff
147
+ - โœ… **Technical Indicators** - Built-in SMA, RSI, MACD, etc.
148
+ - โœ… **CLI Tool** - Command-line interface included
149
+
150
+ ## ๐Ÿ“š Documentation
151
+
152
+ ### Authentication
153
+
154
+ ```python
155
+ # Method 1: Environment variable (recommended)
156
+ export OILPRICEAPI_KEY="your_api_key"
157
+ client = OilPriceAPI()
158
+
159
+ # Method 2: Direct initialization
160
+ client = OilPriceAPI(api_key="your_api_key")
161
+
162
+ # Method 3: With configuration
163
+ client = OilPriceAPI(
164
+ api_key="your_api_key",
165
+ timeout=30,
166
+ max_retries=3,
167
+ cache="memory",
168
+ cache_ttl=300
169
+ )
170
+ ```
171
+
172
+ ### Available Commodities
173
+
174
+ - `BRENT_CRUDE_USD` - Brent Crude Oil
175
+ - `WTI_USD` - West Texas Intermediate
176
+ - `NATURAL_GAS_USD` - Natural Gas
177
+ - `DIESEL_USD` - Diesel
178
+ - `GASOLINE_USD` - Gasoline
179
+ - `HEATING_OIL_USD` - Heating Oil
180
+ - [View all commodities](https://docs.oilpriceapi.com/commodities)
181
+
182
+ ### Error Handling
183
+
184
+ ```python
185
+ from oilpriceapi.exceptions import OilPriceAPIError, RateLimitError, DataNotFoundError
186
+
187
+ try:
188
+ price = client.prices.get("INVALID_CODE")
189
+ except DataNotFoundError as e:
190
+ print(f"Commodity not found: {e}")
191
+ except RateLimitError as e:
192
+ print(f"Rate limited. Resets in {e.seconds_until_reset}s")
193
+ except OilPriceAPIError as e:
194
+ print(f"API error: {e}")
195
+ ```
196
+
197
+ ## โšก Async Support
198
+
199
+ ```python
200
+ import asyncio
201
+ from oilpriceapi import AsyncOilPriceAPI
202
+
203
+ async def get_prices():
204
+ async with AsyncOilPriceAPI() as client:
205
+ prices = await asyncio.gather(
206
+ client.prices.get("BRENT_CRUDE_USD"),
207
+ client.prices.get("WTI_USD"),
208
+ client.prices.get("NATURAL_GAS_USD")
209
+ )
210
+ return prices
211
+
212
+ # Run async function
213
+ prices = asyncio.run(get_prices())
214
+ ```
215
+
216
+ ## ๐Ÿ› ๏ธ CLI Tool
217
+
218
+ ```bash
219
+ # Get current price
220
+ oilprice get BRENT_CRUDE_USD
221
+
222
+ # Export historical data
223
+ oilprice export WTI_USD --start 2024-01-01 --format csv -o wti_2024.csv
224
+
225
+ # Watch prices in real-time
226
+ oilprice watch BRENT_CRUDE_USD --interval 60
227
+ ```
228
+
229
+ ## ๐Ÿงช Testing
230
+
231
+ The SDK includes utilities for testing your applications:
232
+
233
+ ```python
234
+ from oilpriceapi.testing import MockClient
235
+
236
+ def test_my_strategy():
237
+ client = MockClient()
238
+ client.set_price("BRENT_CRUDE_USD", 75.50)
239
+
240
+ result = my_trading_strategy(client)
241
+ assert result.action == "BUY"
242
+ ```
243
+
244
+ ## ๐Ÿ“ˆ Examples
245
+
246
+ Check out the [examples/](examples/) directory for:
247
+ - [Quickstart Notebook](examples/quickstart.ipynb)
248
+ - [Data Analysis](examples/data_analysis.ipynb)
249
+ - [Trading Signals](examples/trading_signals.ipynb)
250
+ - [Async Operations](examples/async_example.py)
251
+
252
+ ## ๐Ÿ”ง Development
253
+
254
+ ```bash
255
+ # Clone repository
256
+ git clone https://github.com/oilpriceapi/python-sdk
257
+ cd python-sdk
258
+
259
+ # Install development dependencies
260
+ pip install -e ".[dev]"
261
+
262
+ # Run tests
263
+ pytest
264
+
265
+ # Format code
266
+ black .
267
+
268
+ # Type checking
269
+ mypy oilpriceapi
270
+ ```
271
+
272
+ ## ๐Ÿ“ License
273
+
274
+ MIT License - see [LICENSE](LICENSE) file for details.
275
+
276
+ ## ๐Ÿค Contributing
277
+
278
+ Contributions are welcome! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
279
+
280
+ ## ๐Ÿ’ฌ Support
281
+
282
+ - ๐Ÿ“ง Email: support@oilpriceapi.com
283
+ - ๐Ÿ› Issues: [GitHub Issues](https://github.com/oilpriceapi/python-sdk/issues)
284
+ - ๐Ÿ“– Docs: [Documentation](https://docs.oilpriceapi.com/sdk/python)
285
+
286
+ ## ๐Ÿ”— Links
287
+
288
+ - [OilPriceAPI Website](https://oilpriceapi.com)
289
+ - [API Documentation](https://docs.oilpriceapi.com)
290
+ - [Pricing](https://oilpriceapi.com/pricing)
291
+ - [Status Page](https://status.oilpriceapi.com)
292
+
293
+ ---
294
+
295
+ Made with โค๏ธ by the OilPriceAPI Team