-
Notifications
You must be signed in to change notification settings - Fork 14
feat: add toncenter overview and rate limit pages #1054
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
laviniat1996
wants to merge
49
commits into
main
Choose a base branch
from
overview
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+224
−0
Open
Changes from 46 commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
ccf1834
add ton center overview + rate limit pages
laviniat1996 fd1baa4
fix linting
laviniat1996 63cff40
Merge branch 'main' into overview
laviniat1996 b879baa
Merge branch 'main' into overview
laviniat1996 cc23a56
fixes
laviniat1996 d55bb26
fix(ci): do not skip empty suggestions (#1065)
Gusarich 025d5b5
feat(structure): tvm/serialization -> foundations/serialization, ecos…
laviniat1996 a4c275c
update docs.json after structure move
laviniat1996 a670d5a
fix(ecosystem.node): mylocalton improvements (#1062)
hacker-volodya 6fdeb62
feat(styleguide): improvements (#1061)
Gusarich a1afbaa
feat(tvm): gas page (#1056)
hacker-volodya cdfb7d1
fix(func): improve types article (#978)
aigerimu 79968fd
upd(jettons/tokens): add decimals (#1076)
skywardboundd 61d0252
feat(styleguide): ban relative links (#1081)
Gusarich 3f00cc2
feat(guides): improve "Make a dApp" article (#999)
aigerimu 405c770
feat: preprocessed wallet v2 (#972)
pyAndr3w b18eff7
fix: feedback on "hands-on debugging" (#927)
aigerimu 09f2590
feat: blockchain sharding and hypercube routing page (#926)
Karkarmath 37e0f5b
feat(wallet contracts): better illustrations (#887)
aigerimu 1043bee
refactor: split nft page into several pages (#743)
skywardboundd 13a5b2b
feat: contract upgrades (#706)
skywardboundd 70f4b8d
feat: tonviewer wording/images (#576)
aigerimu 009f84c
Convert tblkch latex to web whitepaper v2 (#921)
fakela 4556a1d
fix: stronger style rules for filenames
verytactical affe710
Merge branch 'main' into overview
laviniat1996 5be1929
fix linting
laviniat1996 32424b9
ai fixes
laviniat1996 ab89227
fix linting
laviniat1996 7613300
fix spelling
laviniat1996 ec9ce0e
Merge branch 'main' into overview
laviniat1996 a557b1d
Merge branch 'main' into overview
anton-trunov 272c798
Merge branch 'main' into overview
anton-trunov c7088cd
fix spelling
laviniat1996 b41332b
Merge branch 'main' into overview
laviniat1996 090be59
Update ecosystem/api/toncenter/overview.mdx
laviniat1996 7c25b4c
Update ecosystem/api/toncenter/overview.mdx
laviniat1996 a30dd12
Update ecosystem/api/toncenter/rate-limit.mdx
laviniat1996 6487149
Update ecosystem/api/toncenter/rate-limit.mdx
laviniat1996 65e798b
Update ecosystem/api/toncenter/rate-limit.mdx
laviniat1996 796b876
Update ecosystem/api/toncenter/rate-limit.mdx
laviniat1996 b73198d
Update ecosystem/api/toncenter/overview.mdx
laviniat1996 cac3617
fix linting
laviniat1996 bb58a08
fix linting
laviniat1996 90e12df
fix linting
laviniat1996 be8ecaf
fix linting
laviniat1996 c56f8c0
Merge branch 'main' into overview
laviniat1996 06cee22
Rate limiting rules updated (#1327)
kdimentionaltree 15feef2
Merge branch 'main' of https://github.com/ton-org/docs into overview
laviniat1996 425b3b4
fix nav
laviniat1996 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,139 @@ | ||
| --- | ||
| title: "Overview" | ||
| title: Overview | ||
| description: Learn what the TON Center APIs provide and how to use them. | ||
| --- | ||
|
|
||
| import { Stub } from '/snippets/stub.jsx'; | ||
| The **TON Center API** provides developer access to the TON blockchain through REST and JSON-RPC endpoints. | ||
| It allows applications to read blockchain data, run smart contract methods, and send transactions. | ||
|
|
||
| <Stub issue="731" /> | ||
| TON Center serves as a public gateway to the TON network. It implements two types APIs, **API v2** and **API v3**, that correspond to the non-indexed and indexed access layers. | ||
|
|
||
| Applications interact with the TON blockchain by connecting to a TON node. | ||
| Since nodes communicate through the binary ADNL protocol, an intermediate layer | ||
| is needed for web-based access. API v2 provides this bridge by using [`tonlib`](https://github.com/ton-blockchain/ton/tree/master/tonlib/tonlib) | ||
| to query data from liteservers and exposes it | ||
| through a standard REST interface. API v3 extends this model by reading raw data from a node’s | ||
| RocksDB storage, parsing and decoding that data, and storing it in PostgreSQL. | ||
|
|
||
| ## Base URLs | ||
|
|
||
| | API | Mainnet | Testnet | | ||
| | ---------- | ------------------------------ | -------------------------------------- | | ||
| | **API v2** | `https://toncenter.com/api/v2` | `https://testnet.toncenter.com/api/v2` | | ||
| | **API v3** | `https://toncenter.com/api/v3` | `https://testnet.toncenter.com/api/v3` | | ||
|
|
||
| ## Typical use cases | ||
|
|
||
| ### API v2 | ||
|
|
||
| - Query account balances and state | ||
| - Run get-methods on smart contracts | ||
| - Send or broadcast messages | ||
| - Retrieve latest transactions and block information | ||
|
|
||
| ### API v3 | ||
|
|
||
| - Query historical transactions and traces | ||
| - Retrieve decoded Jetton and NFT data | ||
| - Run analytical or filtered searches across multiple accounts | ||
| - Power explorers or reporting tools | ||
|
|
||
| ## Endpoints API v2 | ||
|
|
||
| | Category | Method | Description | | ||
| | ----------------------------- | ------------------------------------- | --------------------------------------------------------- | | ||
| | **Accounts** | `GET /detectAddress` | Detect all address formats and return normalized versions | | ||
| | **Accounts** | `GET /getAddressBalance` | Get balance for an address | | ||
| | **Accounts** | `GET /getAddressInformation` | Get account info including balance and state | | ||
| | **Accounts** | `GET /getExtendedAddressInformation` | Extended account info (wallet type, seqno, etc) | | ||
| | **Accounts** | `GET /getJettonBalances` | Get Jetton balances for a wallet | | ||
| | **Accounts** | `GET /getMasterchainInfoExt` | Get extended masterchain info | | ||
| | **Accounts** | `GET /getNftItemsByCollectionAddress` | Get NFT items by collection | | ||
| | **Accounts** | `GET /getTokenData` | Get Jetton metadata by master address | | ||
| | **Accounts** | `GET /packAddress` | Convert raw address to user-friendly format | | ||
| | **Accounts** | `GET /unpackAddress` | Convert user-friendly address to raw format | | ||
| | **Blocks** | `GET /getBlockHeader` | Get block header metadata | | ||
| | **Blocks** | `GET /getBlockTransactions` | Get transactions in a block | | ||
| | **Blocks** | `GET /getConfigParam` | Get specific config parameter | | ||
| | **Blocks** | `GET /getConfigAll` | Get all config parameters | | ||
| | **Blocks** | `GET /getMasterchainBlockSignatures` | Get masterchain block signatures | | ||
| | **Blocks** | `GET /getMasterchainInfo` | Get last masterchain block info | | ||
| | **Blocks** | `GET /getRawBlockHeader` | Get raw block header | | ||
| | **Blocks** | `GET /getRawMasterchainInfo` | Get raw masterchain info | | ||
| | **Blocks** | `GET /getRawShardBlockHeader` | Get raw shard block header | | ||
| | **Blocks** | `GET /getTime` | Get server time | | ||
| | **Blocks** | `GET /lookupBlock` | Lookup block by seqno/lt/root hash | | ||
| | **Config** | `GET /getConfigParam` | Get specific config parameter | | ||
| | **Config** | `GET /getConfigAll` | Get all config parameters | | ||
| | **Transactions** | `GET /getTransactions` | Get account transactions | | ||
| | **Transactions** | `GET /tryLocateSourceTx` | Try to find source transaction by message hash | | ||
| | **Transactions** | `GET /tryLocateResultTx` | Try to find result transaction by message hash | | ||
| | **Messages and transactions** | `POST /sendBoc` | Send BoC to the network | | ||
| | **Messages and transactions** | `POST /sendBocReturnHash` | Send BoC and return its hash | | ||
| | **Messages and transactions** | `POST /sendQuery` | Send external query to liteserver | | ||
| | **Messages and transactions** | `GET /tryLocateTx` | Try to find transaction by message hash | | ||
| | **Smart contracts** | `POST /runGetMethod` | Run a get-method on a smart contract | | ||
| | **JSON-RPC** | `POST /jsonRPC` | Proxy JSON-RPC requests to liteservers | | ||
|
|
||
| ## Endpoints API v3 | ||
|
|
||
| | Category | Method | Description | | ||
| | -------------------------- | ----------------------------------------- | -------------------------------------------------------------------------- | | ||
| | **Accounts** | `GET /accounts` | List or search accounts with filters | | ||
| | **Accounts** | `GET /accounts/{account_id}` | Get account details by ID | | ||
| | **Accounts** | `GET /accounts/{account_id}/transactions` | List transactions for an account | | ||
| | **Accounts** | `GET /accounts/{account_id}/actions` | List high-level actions for an account (DEX, Jettons, NFTs, etc) | | ||
| | **Actions and traces** | `GET /actions` | List decoded high-level actions like swaps, transfers, or stake operations | | ||
| | **Actions and traces** | `GET /traces` | List full transaction traces with filters and pagination | | ||
| | **Actions and traces** | `GET /emulateTrace` | Emulate a transaction trace for a given external message or BoC | | ||
| | **Actions and traces** | `GET /emulateActions` | Classify emulated traces into actions | | ||
| | **Blockchain data** | `GET /transactions/{hash}` | Get transaction by hash | | ||
| | **Blockchain data** | `GET /transactionsByMessage` | Find transactions by message hash | | ||
| | **Blockchain data** | `GET /blocks/{workchain}/{shard}/{seqno}` | Get a specific block by coordinates | | ||
| | **Blockchain data** | `GET /blocks` | Search or filter blocks with pagination | | ||
| | **Blockchain data** | `GET /messages/{hash}` | Get message by hash | | ||
| | **Blockchain data** | `GET /messages` | Search messages with filters | | ||
| | **Blockchain data** | `GET /validators` | Get current validators and info | | ||
| | **Blockchain data** | `GET /masterchain` | Get masterchain status | | ||
| | **Blockchain data** | `GET /shards` | List active shards and their info | | ||
| | **Blockchain data** | `GET /workchains` | List all configured workchains | | ||
| | **Jettons** | `GET /jettons` | List all Jetton contracts | | ||
| | **Jettons** | `GET /jettons/{master}` | Get Jetton master contract info | | ||
| | **Jettons** | `GET /jettons/{master}/holders` | List holders of a Jetton | | ||
| | **Jettons** | `GET /jettons/{master}/transactions` | Get Jetton transactions | | ||
| | **NFTs** | `GET /nfts` | List NFTs (items or collections) | | ||
| | **NFTs** | `GET /nfts/{collection}` | Get NFT collection details | | ||
| | **NFTs** | `GET /nfts/{collection}/{item}` | Get specific NFT item details | | ||
| | **DNS** | `GET /dns/{domain}` | Resolve TON DNS records | | ||
| | **Utils** | `GET /estimateFee` | Estimate fees for an external message | | ||
| | **Utils** | `GET /detectAddress` | Normalize and inspect address formats | | ||
| | **Stats and analytics** | `GET /stats` | Retrieve aggregated network and protocol statistics | | ||
| | **Legacy (v2-compatible)** | `POST /runGetMethod` | Run get-method | | ||
| | **Legacy (v2-compatible)** | `POST /sendBoc` | Send BoC | | ||
| | **Legacy (v2-compatible)** | `POST /sendBocReturnHash` | Send BoC and return hash | | ||
| | **Legacy (v2-compatible)** | `GET /getAddressInformation` | Get address info | | ||
| | **Legacy (v2-compatible)** | `GET /getTransactions` | Get transactions | | ||
|
|
||
| ## How to access the API | ||
|
|
||
| Developers can access TON Center APIs either through hosted infrastructure managed by TON Center or by running their own instance. | ||
|
|
||
| ### Managed Service | ||
|
|
||
| Hosted access uses TON Center’s managed infrastructure instead of running a personal node. This approach enables | ||
| immediate network access without setup or maintenance. | ||
|
|
||
| Requests without an API key are limited to a default rate of 1 request per second. | ||
|
|
||
| To increase this limit or access private liteservers, generate an [API key](/ecosystem/api/toncenter/get-api-key) and [choose a plan](/ecosystem/api/toncenter/rate-limit). | ||
|
|
||
| ### Self-hosted service | ||
|
|
||
| Run a self-hosted TON Center infrastructure for full control over performance and data retention. | ||
|
|
||
| - [API v2](https://github.com/toncenter/ton-http-api) | ||
| - [API v3](https://github.com/toncenter/ton-indexer) | ||
|
|
||
| ### Minimum recommended configuration | ||
|
|
||
| 16-core CPU, 128 GB RAM, 1 TB NVMe SSD, and 1 Gbps network connection. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| --- | ||
| title: "Managed plans and rate limiting" | ||
| description: "Understand TON Center API rate limits." | ||
| --- | ||
|
|
||
| import {Aside} from "/snippets/aside.jsx"; | ||
|
|
||
| To ensure stability and fair access, TON Center applies rate limits to all API requests.\ | ||
| If an application exceeds these limits, the API returns a `429` response. | ||
|
|
||
| Increase limits by [requesting an API key](/ecosystem/api/toncenter/get-api-key) and selecting a higher subscription plan. | ||
| Without any API key, the default rate limit is 1 request per second. | ||
|
|
||
| ## Default limits | ||
|
|
||
| | Plan | Tokens per Network | Requests per Second | Notes | | ||
| | -------------- | ------------------ | ------------------- | ----------------------------------------------------------------------------------------------------------- | | ||
| | **Free** | 1 | 10 | Shared liteservers, ideal for quick tests and small projects. | | ||
| | **Plus** | 3 | 25 | Private liteservers for more consistent performance. | | ||
| | **Advanced** | 10 | 100 | Private infrastructure with priority routing. | | ||
| | **Enterprise** | Custom | Custom | Tailored throughput and support. Contact [@toncenter\_support](https://t.me/toncenter_support) for details. | | ||
|
|
||
| Rate limits apply per API token and per network (mainnet/testnet). | ||
|
|
||
| <Aside> | ||
| Each token represents an individual API key used to authenticate requests. | ||
| Plans differ by how many tokens can be generated per network (mainnet and testnet). | ||
| For example, the "Free" plan allows 1 key per network, while higher plans provide multiple keys for separate apps or environments. | ||
| </Aside> | ||
|
|
||
| ## Rate limit exceeded | ||
|
|
||
| When requests are sent faster than the allowed rate limit, the TON Center API temporarily blocks new ones. | ||
| A JSON response indicates the rate limit was exceeded: | ||
|
|
||
| ```json | ||
| { | ||
| "ok": false, | ||
| "result": "Ratelimit exceed", | ||
| "code": 429 | ||
| } | ||
| ``` | ||
|
|
||
| When this occurs: | ||
|
|
||
| - Stop sending new requests and wait a few seconds before retrying. | ||
| - Implement exponential backoff to avoid repeated rate-limit violations. | ||
|
|
||
| ## Common mistakes | ||
|
|
||
| If a paid plan is active but the rate remains 1 RPS: | ||
|
|
||
| - Check that your API key is included correctly in your requests. | ||
| Requests without a valid API key are limited to 1 RPS, even if a subscription is active. | ||
|
|
||
| - Verify the correct key is used for the intended environment (mainnet or testnet). | ||
| Each network requires its own key. | ||
|
|
||
| Wait up to 10 minutes after upgrading the plan or changing the API key. | ||
| Subscription and key updates can take several minutes to propagate across TON Center’s rate-limiting system. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.