TON API
TON API Ecosystem comprises a comprehensive suite of development resources and interfaces designed to facilitate seamless interaction with the TON blockchain network.
This toolkit encompasses a diverse array of official and community-contributed software development kits (SDKs), supporting multiple programming languages. These resources empower developers to efficiently create and deploy decentralized applications (dApps) on TON platform, streamlining the process of blockchain integration and enabling innovative solutions within the TON Ecosystem.
TON API v2
TON API v2 introduces several improvements and new features compared to its predecessor:
Accounts
- Retrieve detailed information using unique identifiers
- Access owned NFT items via specific IDs
- Obtain Jetton balance data through designated keys
- View individual Jetton balances with combined identifiers
- Access transaction history for Jettons
- Retrieve specific Jetton transaction records
- Fetch owned NFT items list
- Access associated event information
- Obtain details of particular events
- Retrieve related trace data
- View subscription information
- Reindex account data (POST request)
Streaming API
- Introduced in TON API v2
- Gets real-time updates on blockchain events
- Utilizes Server-Sent Events (SSE) for pushing updates to clients
- Offers live data feeds for new blocks, finalized transactions, traces, and pending messages
- Particularly useful for applications requiring real-time blockchain data
GraphQL API
- Offers a flexible interface for querying and mutating data
- Accessible via a dedicated API endpoint
- Includes a GraphQL Playground for interactive query exploration and testing
- Allows developers to efficiently fetch specific data in a single request
- Enhances data retrieval efficiency and flexibility
NFT
- Retrieve comprehensive collection listings
- Access detailed information for specific collections
- Fetch items from individual collections using unique identifiers
- Obtain NFT items through bulk address list submission (POST request)
Jettons
- Access complete catalog of available Jettons
- Retrieve detailed information for individual Jettons
- Obtain holder data for specific Jetton instances
- Generate transfer payload using recipient and Jetton identifiers
- Access event information associated with particular Jettons
DNS
- Acquire detailed DNS information for specified domain names
- Perform domain name resolution to associated TON addresses
- Retrieve comprehensive bid information for specific domains
- Access listings of all currently active DNS auctions
Wallet
- Retrieve a wallet backup (GET request)
- Set a wallet backup (PUT request)
- Perform TON Connect proof (POST request)
- Get the current seqno (sequence number) for an account by providing the account ID
- Fetch wallets associated with a specific public key
- Emulate sending a message to a wallet (POST request)
Rates
- Retrieve current exchange rates for various currencies
- Get historical exchange rates for charting purposes
- Fetch exchange rates from different markets
Staking
- Get the list of staking pools nominated by a specific account using the account ID
- Retrieve information about a specific staking pool by providing its account ID
- Fetch the staking history for a specific pool using the pool's account ID
- Get a list of all available staking pools
Traces
- Retrieve details of a specific trace by providing the trace ID
- Emulate sending a message to a trace (POST request)
Multisig
- Get details of a multisignature wallet by specifying its account ID
Blockchain
- Fetch a list of reduced (simplified) blockchain blocks
- Retrieve a specific block by its block ID
- Get shard information for a specific masterchain block using the masterchain's sequence number
- Fetch blocks from a specific masterchain using the masterchain's sequence number
- Retrieve transactions from a specific masterchain block by providing the masterchain's sequence number
- Get the blockchain configuration from a specific block using the masterchain's sequence number
- Fetch the raw blockchain configuration from a block by specifying the masterchain's sequence number
- Retrieve transactions from a specific block using the block ID
- Get details of a specific transaction by providing the transaction ID
- Fetch a transaction by its message hash
- Retrieve a list of blockchain validators
- Get the current masterchain head (the latest masterchain block)
- Fetch raw account details from the blockchain using the account ID
- Retrieve transactions associated with a specific account by providing the account ID
- Execute a get method for a specific account using the account ID and method name
These endpoints provide developers with a wide range of tools to interact with TON Blockchain, allowing them to retrieve data, post data, and emulate various blockchain interactions. The API is designed to be flexible and cater to a variety of use cases, from building wallets and explorers to analyzing blockchain data and creating complex smart contract interactions.
Schemas
- Provides a comprehensive list of data structures and types used within the API
- Defines the structure and format of entities such as errors, account addresses, blocks, transactions, and messages
- Ensures developers have a clear understanding of the data they will be working with
- Helps maintain consistency and integrity across different endpoints and responses
Emulation
- Offers functionality for simulating and testing blockchain actions and messages without impacting the main network
- Allows developers to decode messages and emulate messages to events, traces, wallets, and specific account events
- Requires developers to provide necessary parameters such as the message to be decoded or relevant event, trace, wallet, or account details
- Enables developers to validate their applications and test different scenarios in a controlled environment before deploying on the main blockchain
Inscriptions
- Focuses on managing and retrieving account inscriptions, which are on-chain data or metadata associated with specific accounts
- Provides endpoints to retrieve inscriptions for a particular account, fetch the history of account inscriptions, and retrieve inscription history by ticker
- Allows developers to work with account inscriptions and potentially use them for various applications or analytics purposes
Utilities
- Offers helper endpoints for common tasks and information retrieval
- Allows developers to check the current status of the API service, ensuring the availability and health of the API
- Provides functionality to parse account addresses, making it easier to work with and validate TON blockchain addresses
Lite Server
- Provides endpoints for interacting with a lightweight node, which is a more resource-efficient way to access blockchain data
- Enables developers to retrieve information about the masterchain, the current time, specific blocks, and block states
- Allows sending raw messages to the blockchain, retrieving account states, and fetching shard information
- Offers functionality to retrieve transaction data for specific accounts and blocks
- Provides endpoints for fetching block proofs, shard block proofs, and retrieving configuration data from blocks
- Enables developers to access the sizes of the output message queue, which can be useful for monitoring and optimizing application performance
Cookbook and Gasless Transfers
- Cookbook section in documentation provides implementation examples
- Includes examples for different operations of blockchain
- Features gasless transfers, allowing transactions without direct gas fee payment by the sender
- Gasless transfers can improve user experience in certain applications
- Offers code examples in multiple programming languages for easier integration
Official Development Kits
TON Ecosystem provides ready-made development tools for various coding languages, designed for efficient project integration:
- Go-based SDK: tonapi-go
- JS/TS Client: @ton-api/client
- Legacy JS/TS SDK: tonapi-sdk-js
- Compatibility Layer: Enhances applications with extended blockchain capabilities
Community Contributions
The Ecosystem also includes community-supported tools for expanded language coverage:
- Python Implementation: Available on GitHub
Custom SDK Creation
For developers seeking personalized solutions:
- Locate the API specification document
- Employ appropriate tools to generate code in your preferred language
- Implement the resulting code into your development environment
Subscription Options
The API service is available through multiple tiers, with pricing determined by usage requirements.
Pricing
TON API offers multiple pricing plans based on usage volume:
- Free (Forever Free): 1 request/sec, 1 realtime connection, watch up to 5 blockchain accounts
- Lite ($9.9/month): 10 requests/sec, 5 realtime connections, watch up to 10 accounts, event streaming
- Standard ($95/month): 100 requests/sec, 50 realtime connections, watch up to 50 accounts, event streaming
- Plus ($290/month): 300 requests/sec, 1000 realtime connections, watch up to 100 accounts, event streaming
- Heavy ($890/month): 1000 requests/sec, 1000 realtime connections, watch up to 1000 accounts, event streaming
Custom plans with unlimited requests/sec and realtime connections are also available.
By providing a range of SDKs, an adapter for @ton/ton compatibility, and a Swagger specification for custom SDK generation, TON API has developers flexible options to build applications interfacing with TON Blockchain.