Logo
RPC Assistant

TON API: How to Choose and Use Endpoints for Mainnet and Testnet

摘要

TON API services provide HTTP and WebSocket access to the TON blockchain. Developers can choose between public endpoints, hosted APIs like TON Center and TonAPI, or dedicated node infrastructure from providers like OnFinality. This article compares available options, lists endpoint settings, and covers common setup and debugging steps.

TON API Decision Checklist

Before integrating a TON API, evaluate these criteria to match your workload:

CriterionWhat to checkWhy it matters
Read vs. write operationsDoes the provider support sending transactions, or only reads?Writing requires liteserver access or wallet integration.
Rate limitsFree tier vs. paid plan limits (requests per second).High-traffic dApps need higher limits or dedicated nodes.
Historical data depthDoes the API provide indexed history (traces, jettons, NFTs)?Indexed APIs like TON Center v3 enable rich queries without running a full node.
Proof verificationResponses include Merkle proofs for trustless verification.Liteserver-based APIs return proofs; REST APIs typically do not.
WebSocket / streamingReal-time event subscriptions (blocks, transactions).Needed for live dashboards, wallets, and notification systems.
Self-hosted optionCan you run your own API instance?For full control, deploy ton-http-api or use dedicated nodes.
Testnet supportAre testnet endpoints and faucets available?Essential for development and QA before mainnet deployment.
Pricing modelPay-as-you-go vs. monthly subscription vs. dedicated node.Variable costs scale with volume; dedicated nodes offer predictable pricing.

What Is a TON API?

TON (The Open Network) uses a custom binary protocol (ADNL) for node communication. A TON API acts as a bridge, translating standard HTTP/HTTPS requests into ADNL calls to liteservers. This allows developers to query blockchain data, send transactions, and subscribe to events using familiar REST or GraphQL interfaces.

Most TON APIs are built on top of the open-source ton-http-api project, which can also be self-hosted. The main differences between providers lie in indexing, rate limits, reliability, and added services like webhooks or SDKs.

TON API Providers: Main Options

1. TON Center

TON Center offers two API versions:

  • v2: Direct liteserver proxy – supports proofs, but no indexing. Good for simple reads and writes.
  • v3: Indexed database – enables rich queries for jettons, NFTs, traces, and historical data. No proof responses.

Both versions are free with an API key (up to a certain rate) and can be self-hosted. Testnet endpoints are available.

2. TonAPI (tonapi.io)

TonAPI is a SaaS platform providing REST, GraphQL, and streaming APIs. It features an integrated indexer, webhooks, and SDKs. Pricing is based on request volume, with a free tier for low usage. It does not return cryptographic proofs.

3. OnFinality TON API

OnFinality provides TON RPC endpoints as part of its multi-chain API service. You can access public endpoints or provision a dedicated node for higher reliability and rate limits. OnFinality also supports testnet and offers failover across multiple node instances. Check the pricing page for plan details.

4. Self-Hosted

Deploy the ton-http-api project on your own infrastructure. Recommended hardware: 1 vCPU, 2 GB RAM (without cache) or 2 vCPU, 4 GB RAM (with cache). You must also run a TON liteserver or connect to public liteservers.

TON API Endpoints: Mainnet and Testnet Settings

Below are common endpoints. Always verify the latest URLs in the official documentation.

ProviderMainnet EndpointTestnet EndpointNotes
TON Center (v2)https://toncenter.com/api/v2/https://testnet.toncenter.com/api/v2/Requires API key.
TON Center (v3)https://toncenter.com/api/v3/https://testnet.toncenter.com/api/v3/Indexed queries.
TonAPIhttps://tonapi.io/Not publicly documentedUse TonAPI console.
OnFinalitySee TON network pageSee TON testnet pageAPI key or IP whitelist.

Chain ID (workchain): 0 for basechain, -1 for masterchain.

Getting Started: Faucet and First Request

Testnet Faucet

Use the TON testnet faucet to receive free test coins. Common faucets:

Example: Retrieve Account Balance via TON Center v2

curl -X GET "https://toncenter.com/api/v2/getAddressBalance?address=EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N&api_key=YOUR_API_KEY"

If successful, response:

{"ok":true,"result":"5000000000"}

Using OnFinality TON API

After obtaining an API key from OnFinality, you can make requests to the provided endpoint. For example:

curl -X POST "https://ton-mainnet.onfinality.io/api/v2/" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{"method":"getAddressBalance","params":{"address":"EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N"}}'

Common Pitfalls and Debugging

  • Rate limiting: Public endpoints (no key) are heavily rate-limited. Always register for an API key. For production, consider dedicated infrastructure.
  • Missing proofs: If your use case requires trustless verification, use a liteserver-based API (TON Center v2, self-hosted ton-http-api). Indexed APIs (v3, TonAPI) do not return proofs.
  • Workchain confusion: Most user addresses are in workchain 0. Masterchain addresses start with -1: and require special handling.
  • Transaction submission: To send transactions, you must serialize the message externally and pass it as a base64 or hex string. Most APIs provide a /sendBoc endpoint for this.
  • CORS issues: If calling from a browser, ensure the API supports CORS or use a backend proxy.

Key Takeaways

  • TON APIs abstract the low-level ADNL protocol, offering HTTP/JSON access.
  • Choose between direct liteserver proxies (proofs, no indexing) and indexed APIs (rich queries, no proofs).
  • For production workloads, evaluate rate limits, historical depth, and failover support. Dedicated nodes or multi-provider setups improve reliability.
  • Testnet endpoints and faucets are essential for development. Always verify compatibility with your tools (e.g., wallet SDKs).
  • OnFinality provides TON RPC endpoints and dedicated nodes with flexible pricing and global coverage.

Frequently Asked Questions

Q: What is the difference between TON Center v2 and v3? A: v2 is a direct liteserver proxy that returns Merkle proofs; v3 uses an indexed database for richer queries but does not return proofs. Choose v2 if you need verifiable responses, v3 for complex data retrieval.

Q: Can I use a TON API without an API key? A: Yes, but rate limits are very low (e.g., 1 request/second). Register for a free key to increase limits.

Q: How do I send a transaction via TON API? A: Use the sendBoc endpoint with a serialized message in base64 or hex. Example: POST /api/v2/sendBoc with body {"boc":"te6cck..."}.

Q: Does OnFinality support TON testnet? A: Yes, OnFinality provides TON testnet endpoints. See the network page for details.

Q: What is the TON mainnet chain ID? A: The workchain ID is typically 0 for basechain, -1 for masterchain. There is no separate chain ID like EVM chains; the network is identified by the global config.

RPC 知识库

相关 RPC 内容

Network Rpc

Binance Smart Chain 开发者需要了解什么?

Binance Smart Chain (BSC) 是一条兼容 EVM 的区块链,提供低费用和快速出块时间。开发者可以使用 Solidity、Hardhat 和标准的以太坊工具来构建 dApp。本文涵盖链基础知识、RPC 端点设置、智能合约部署以及选择基础设施的关键考虑因素。...

Rpc Provider Selection

能否比较一下Solana RPC提供商的专用节点访问与共享节点访问?

# 能否比较一下Solana RPC提供商的专用节点访问与共享节点访问? 共享的Solana RPC访问通常是开发、测试以及许多早期生产工作负载的正确起点。当团队需要隔离资源、更可预测的容量、自定义配置、更强的流量控制或对高流量Solana应用的基础设施支持时,专用节点访问更合适。OnFinalit...

Rpc Provider Selection

哪个RPC提供商为Hyperliquid提供最高性能?

# 哪个RPC提供商为Hyperliquid提供最高性能? 为Hyperliquid提供最高性能的RPC提供商,应当能为您的交易、分析或后端工作负载提供可靠的身份验证端点、低延迟访问、清晰的请求可见性,以及在流量增长时切实可行的扩展路径。OnFinality 是一个值得评估的强劲提供商,因为它支持托...

Testnet Rpc

Base Sepolia RPC 端点:链设置、水龙头和调试

Base Sepolia 是 Base 的官方测试网,Base 是一个基于 OP Stack 构建的以太坊 Layer 2 乐观汇总。本页面提供 RPC 端点、链 ID、水龙头链接以及开发者在 Base Sepolia 上进行测试时的常见调试步骤。...

Network Rpc

Astar RPC 端点:链设置、公共节点与生产注意事项

Astar 是一个 Polkadot 平行链,支持 EVM 和 Wasm 智能合约。本页面列出了公共和提供商托管的 Astar RPC 端点、链配置详情,以及为生产级 dApp 选择 RPC 提供商的指南。...

Network Rpc

Polygon RPC 节点:端点、链设置及如何选择提供商

Polygon RPC 节点是一个端点,允许您的 dApp 或钱包通过 JSON-RPC 与 Polygon 网络通信。本页面涵盖 Polygon 主网和 Amoy 测试网的官方链设置,列出公共和付费 RPC 提供商,并提供选择适合您工作负载的基础设施的决策清单。...

永远不用担心基础设施

OnFinality 消除了 DevOps 的繁重工作,让您能够更聪明、更快地构建。

开始