Skip to main content
This page explains how to install the tonutils library and select the appropriate client depending on your needs.

Installation

Requires Python 3.9 or later. Native ADNL lite clients are included — no optional dependencies needed.

Available Clients

All clients share a common interface and are asynchronous context managers. Use async with client: or call await client.connect() / await client.close() explicitly. The network is selected with NetworkGlobalID.MAINNET or NetworkGlobalID.TESTNET from ton_core. Common constructor parameters: Lite clients additionally accept:
Ready-made retry policies are available in tonutils.types: DEFAULT_HTTP_RETRY_POLICY for HTTP clients and DEFAULT_ADNL_RETRY_POLICY for lite clients. Both are recommended for stability.

HTTP Clients

Toncenter

toncenter.com — official TON Center API (v2).
API key is optional — without a key the client is limited to 1 request per 1.3 seconds. Obtain a key via @toncenter for higher limits.

Tonapi

tonapi.io — Tonapi by Tonkeeper.
API key is optional — without a key the client falls back to a conservative default rate limit (1 request per 4 seconds). Get a key at tonconsole.com for higher limits.

Chainstack

chainstack.com — enterprise blockchain infrastructure.
Requires a personal endpoint URL, obtained on the Chainstack website.

QuickNode

quicknode.com — high-performance RPC.
Requires a personal endpoint URL, obtained on the QuickNode website. QuickNode supports mainnet only — there is no network parameter.

Tatum

tatum.io — multi-chain API platform.
Requires an API key from tatum.io.

HTTP Balancer

HttpBalancer distributes requests across multiple HTTP clients. It selects the best available client based on limiter readiness and error rates, and falls back to round-robin when all clients are equally available. The network parameter is applied to every wrapped client, overriding their own setting (QuicknodeClient is rejected on testnet); request_timeout caps the total time of one operation including all failover attempts.

Lite Clients

LiteClient talks to a single lite server directly over ADNL TCP. There are three ways to create one.
Avoid rps_limit=1 with lite clients — parallel background queries are used to track masterchain updates. Private lite-server configs (available from Tonconsole or the dTON bot) are recommended for production; public servers may be unstable under load.
Use when you have specific server credentials from a private provider. ip accepts a signed 32-bit integer or an IPv4 string; public_key accepts hex, base64, or bytes.

Lite Balancer

LiteBalancer manages multiple lite clients with automatic failover. It selects the best client based on masterchain height and ping RTT, falling back to round-robin when all clients are equally available.
Compose the balancer from LiteClient instances created with private server credentials.

Client Examples

Full runnable initialization scripts for every client and balancer on GitHub.