Skip to main content
Query TON blockchain data through the REST API. The SDK exposes resource groups as attributes on TonapiRestClient.
API key is optional — without a key, requests are throttled to ~1 per 4 seconds. Get a key at tonconsole.com.

Quick Example

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("YOUR_API_KEY", Network.MAINNET) as tonapi:
        account = await tonapi.accounts.get_account(
            account_id="EQDtFpEwcFAEcRe5mLVh2N6C0x-_hJEM7W61_JLnSF74p4q2",
        )
        print(f"Balance: {to_amount(account.balance)} TON")  # balance is in nanotons


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

Resources

ResourceDescription
tonapi.accountsAccount info, balances, events, traces, subscriptions.
tonapi.blockchainBlocks, transactions, validators, config, raw account.
tonapi.connectTON Connect payload and state init.
tonapi.dnsDomain info, resolve, bids, auctions.
tonapi.emulationMessage decoding and event/trace/wallet emulation.
tonapi.eventsEvent lookup and emulation.
tonapi.extra_currencyExtra currency info.
tonapi.gaslessGasless config, estimation, and sending.
tonapi.jettonsJetton info, holders, transfers, events.
tonapi.lite_serverDirect lite server access (raw blockchain data).
tonapi.multisigMultisig accounts and orders.
tonapi.nftCollections, items, history.
tonapi.purchasesPurchase history.
tonapi.ratesToken rates, charts, markets.
tonapi.stakingNominator pools, staking info, history.
tonapi.storageStorage providers.
tonapi.tracesTrace lookup and emulation.
tonapi.utilitiesOpenAPI spec, status, address parsing.
tonapi.walletWallet info, seqno, TON Connect proof, emulation.

Endpoints

NetworkURL
Mainnethttps://tonapi.io
Testnethttps://testnet.tonapi.io
Tetrahttps://tetra.tonapi.io