API Client¶
client ¶
T3 API client built on httpx.
Provides :class:T3APIClient, an async httpx-based client that handles
authentication, retries, and response parsing for the T3 API.
T3APIClient ¶
T3APIClient(*, config: Optional[HTTPConfig] = None, retry_policy: Optional[RetryPolicy] = None, logging_hooks: Optional[LoggingHooks] = None, headers: Optional[Dict[str, str]] = None)
Async T3 API client using httpx.AsyncClient.
This client provides a high-level interface to the T3 API, handling authentication, retries, and response parsing with async/await support for better performance when making many concurrent requests.
Initialize the async T3 API client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Optional[HTTPConfig]
|
HTTP configuration (host, timeout, etc.) |
None
|
retry_policy
|
Optional[RetryPolicy]
|
Retry policy for failed requests |
None
|
logging_hooks
|
Optional[LoggingHooks]
|
Optional request/response logging |
None
|
headers
|
Optional[Dict[str, str]]
|
Additional headers to include with requests |
None
|
Source code in t3api_utils/api/client.py
is_authenticated
property
¶
Check if client is authenticated.
Returns:
| Type | Description |
|---|---|
bool
|
|
access_token
property
¶
Get the current access token.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
The JWT bearer token string, or |
__aenter__
async
¶
__aexit__
async
¶
close
async
¶
set_access_token ¶
Set the access token for authentication.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str
|
Bearer token for API authentication |
required |
Source code in t3api_utils/api/client.py
clear_access_token ¶
Clear the access token and mark the client as unauthenticated.
Removes the Authorization header from the underlying httpx client.
Source code in t3api_utils/api/client.py
authenticate_with_credentials
async
¶
authenticate_with_credentials(*, hostname: str, username: str, password: str, otp: Optional[str] = None, email: Optional[str] = None) -> AuthResponseData
Authenticate with T3 API using credentials.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hostname
|
str
|
The hostname for authentication |
required |
username
|
str
|
Username |
required |
password
|
str
|
Password |
required |
otp
|
Optional[str]
|
Optional one-time password |
None
|
email
|
Optional[str]
|
Optional email address |
None
|
Returns:
| Type | Description |
|---|---|
AuthResponseData
|
AuthResponseData containing access token and metadata |
Raises:
| Type | Description |
|---|---|
T3HTTPError
|
If authentication fails |
Source code in t3api_utils/api/client.py
authenticate_with_api_key
async
¶
Authenticate with T3 API using API key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str
|
API key for the T3 API |
required |
state_code
|
str
|
State code (e.g., "CA", "MO", "CO", "MI") |
required |
Returns:
| Type | Description |
|---|---|
AuthResponseData
|
AuthResponseData containing access token and metadata |
Raises:
| Type | Description |
|---|---|
T3HTTPError
|
If authentication fails |