Skip to content

Async client

The SDK ships an async client, AsyncDatamaxi, built on httpx. It mirrors the sync Datamaxi resource tree — the same endpoints and arguments — with one rule: every method is a coroutine and must be awaited.

Every endpoint page in this documentation carries a Sync / Async tab — switch to the Async tab to see the awaited twin of that page's example.

Installation

The async client requires the async extra, which pulls in httpx:

pip install "datamaxi[async]"

Lifecycle

Use AsyncDatamaxi as an async context manager so the underlying httpx client is closed cleanly, or call await client.aclose() yourself. It reads the same DATAMAXI_API_KEY environment variable as the sync client.

import asyncio
from datamaxi.aio import AsyncDatamaxi


async def main():
    # Reads DATAMAXI_API_KEY from the environment, or pass api_key=... explicitly.
    async with AsyncDatamaxi() as client:
        df = await client.cex.candle(
            exchange="binance", symbol="BTC-USDT", interval="1d", market="spot"
        )
        print(df.head())


asyncio.run(main())

Without a context manager, close the client explicitly:

client = AsyncDatamaxi()
try:
    df = await client.cex.candle(
        exchange="binance", symbol="BTC-USDT", interval="1d", market="spot"
    )
finally:
    await client.aclose()

Notes

  • Every data and discovery method is a coroutine — await it (e.g. await client.cex.candle.exchanges(market="spot")).
  • Telegram and Naver are reached via client.telegram and client.naver. See the Telegram and Naver Trend pages for tabbed examples.

Pagination

Paginated endpoints return an async next_request callable — await it too:

data, next_request = await client.cex.announcement(page=1, limit=100)
data2, _ = await next_request()

Reference

Async entrypoint — full mirror of the sync :class:datamaxi.Datamaxi.

Use as an async context manager so the underlying httpx client is closed, or call :meth:aclose explicitly.