Skip to main content
Query blockchain data via REST, subscribe to real-time events, and receive webhook notifications.

Installation

pip install pytonapi
RequirementVersion
Python3.10+
aiohttp3.9+
pydantic2.0+

Quick Start

import asyncio

from pytonapi.rest import TonapiRestClient
from pytonapi.types import Network
from pytonapi.utils import to_amount


async def main() -> None:
    async with TonapiRestClient(network=Network.MAINNET) as tonapi:
        account = await tonapi.accounts.get_account(
            account_id="EQDtFpEwcFAEcRe5mLVh2N6C0x-_hJEM7W61_JLnSF74p4q2",
        )
        print(f"Balance: {to_amount(account.balance)} TON")


if __name__ == "__main__":
    asyncio.run(main())

More Examples

REST, streaming, webhooks, and transfers.

Explore

REST API

Query accounts, Jettons, NFTs, transactions, and more.

Webhooks

Push notifications for account transactions and mempool messages.

Streaming

Real-time blockchain events over SSE and WebSocket.

AI Plugin

Query TON blockchain through natural language in Claude Code.