Async Client
oilpriceapi.async_client.AsyncOilPriceAPI
Asynchronous client for OilPriceAPI.
Provides async/await support for all API operations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
Optional[str]
|
API key for authentication |
None
|
base_url
|
Optional[str]
|
Base URL for API |
None
|
timeout
|
Optional[float]
|
Request timeout in seconds |
None
|
max_retries
|
Optional[int]
|
Maximum retry attempts |
None
|
Example
async with AsyncOilPriceAPI() as client: ... price = await client.prices.get("BRENT_CRUDE_USD") ... print(f"Brent: ${price.value:.2f}")
request(method, path, params=None, json_data=None, **kwargs)
async
Make async HTTP request to API.
close()
async
Close the HTTP client and flush telemetry.
__aenter__()
async
Async context manager entry.
__aexit__(exc_type, exc_val, exc_tb)
async
Async context manager exit.