Client
polar_flow.client.PolarFlow
Async HTTP client for Polar AccessLink API.
This client provides async-first access to the Polar AccessLink API with automatic error handling, rate limit awareness, and Pydantic model validation.
Example
async with PolarFlow(access_token="your_token") as client:
sleep = await client.sleep.get(user_id="123", date="2026-01-09")
print(sleep.sleep_score)
__init__(access_token, base_url=None)
Initialize the Polar API client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
access_token
|
str
|
OAuth2 access token for authentication |
required |
base_url
|
str | None
|
Optional custom base URL (defaults to production API) |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If access_token is empty or invalid |
__aenter__()
async
Enter async context manager.
Returns:
| Type | Description |
|---|---|
PolarFlow
|
The client instance |
Example
async with PolarFlow(access_token="token") as client:
...
__aexit__(*args)
async
Exit async context manager and cleanup resources.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Any
|
Exception info if any |
()
|