Skip to content

AsyncHTTPClient

AsyncHTTPClient

Asynchronous HTTP client

Attributes

account property

account: LightAccount

Get the LightAccount instance (this is not a web3 contract instance).

active_subaccount property

active_subaccount: Subaccount

Get the currently active subaccount.

bridge property

Get the bridge client for cross-chain transfers.

cached_subaccounts property

cached_subaccounts: list[Subaccount]

Get all cached subaccounts.

collateral property

Manage collateral and margin.

logger property

logger: LoggerType

markets property

Access market data and instruments.

mmp property

Market maker protection settings.

orders property

Place and manage orders.

positions property

positions: PositionOperations

View and manage positions.

rfq property

Request for quote operations.

trades property

View trade history.

transactions property

transactions: TransactionOperations

Query transaction status and details.

Functions

connect async

connect(initialize_bridge: bool = True) -> None

Connect to Derive and validate credentials.

Parameters:

Name Type Description Default
initialize_bridge bool

If True, attempt to initialize bridge client (requires owner signer)

True

disconnect async

disconnect() -> None

Close the underlying session and clear cached state. Idempotent.

fetch_subaccount async

fetch_subaccount(subaccount_id: int) -> Subaccount

Fetch a subaccount from API and cache it.

fetch_subaccounts async

fetch_subaccounts() -> list[Subaccount]

Fetch subaccounts from API and cache them.

from_env classmethod

from_env(
    session_key_path: Path | None = None,
    env_file: Path | None = None,
) -> AsyncHTTPClient

Create the AsyncHTTPClient instance.

timeout async

timeout(seconds: float) -> AsyncGenerator[None, None]

Temporarily overwrite client's AsyncHTTPSession's request_timeout.