@tronscanteam/cli
v1.1.9
Published
TronScan API CLI tool - 86 query commands for TRON blockchain data
Readme
TronScan CLI
A CLI tool built on TronScan API. Besides the global setup command, it implements 86 ts <command> query subcommands: tokens, search, overview, blocks, accounts, governance, transactions, statistics, contracts, security, deep analysis, stablecoins, and raw api access.
Install
Install from npm
npm install -g @tronscanteam/cliThis registers the global command ts for use in any directory. Run ts setup to configure your API Key, and ts help to see all commands.
API Key:
Get your API Key: https://docs.tronscan.org/zh/api/api-keys
ts setup YOUR_API_KEY # replace with your actual API KeyUpgrade and uninstall
npm update -g @tronscanteam/cli
npm uninstall -g @tronscanteam/cliQuick Start
After installation, run queries with these commands:
ts --version
ts help
ts tps --raw
ts block --raw
ts token usdt --rawExpected behavior:
ts --versionprints the installed CLI version.ts helplists available commands and global options.- Query commands return JSON data from TronScan API.
- Use
--rawor--jsonfor one-line JSON that is easier to parse in scripts.
Usage
In the terminal
After installing ts globally, run commands directly:
ts help # list all subcommands
ts token-price trx # token price by symbol
ts token usdt # token info
ts search usdt # search
ts block # latest block
ts tps # current TPS
ts account TXxx... # account details
ts tx af949... # transaction by hash
ts transfer-trc20 TXxx... # TRC20 transfers
ts security-account TXxx... # account risk checkMachine-readable output
All query commands print JSON. By default, the JSON is formatted for reading. Use --raw or --json for compact one-line JSON:
ts tps --raw
ts account TXxx... --jsonNotes for scripts and AI agents:
- Prefer
--rawor--json. - Do not parse colorized or human-facing error text from stderr.
- Business fields come from TronScan API responses and can differ by endpoint.
- Pagination options are
--start Nand--limit N; defaults are0and20.
Exit codes
| Code | Meaning | Suggested handling |
|---:|---|---|
| 0 | Success | Continue. |
| 1 | Unknown command or runtime error (including non-JSON API bodies) | Stop and show the error. |
| 2 | Invalid argument or missing API Key | Fix command arguments or run ts setup. |
| 3 | Network request failed | Check network connectivity and retry later. |
| 4 | HTTP/API request failed | Check API Key, endpoint, parameters, or rate limits. |
Safety model
TronScan CLI is a read-only data query tool for TronScan API. It does not manage wallets, read private keys, sign messages, broadcast transactions, or submit transactions.
Troubleshooting
| Symptom | Fix |
|---|---|
| 未找到 API Key | Run ts setup YOUR_API_KEY or set TRONSCAN_API_KEY in the environment. |
| HTTP 401/403 | Check whether the API Key is valid. |
| HTTP 429 | Reduce request rate and retry later. |
| HTTP 404 | Check the command arguments or API path. |
| Network request failed | Check local network connectivity. |
Dependencies
- Node.js >= 18
Command Categories
| Category | Count | Commands | Scope |
|----------|-------|----------|-------|
| Token | 5 | tokentoken-holderstoken-pricetoken-listtoken-distribution | Token details, holders, prices, rankings, and position distribution. |
| Search | 2 | searchhot-token | Keyword search and hot token rankings. |
| Overview | 3 | tpsoverviewnodes | Network TPS, overview data, and node information. |
| Block | 1 | block | Latest block or a block by number. |
| Account | 10 | accountaccount-listaccount-tokensaccount-resourceaccount-resource-v1account-approveaccount-votesaccount-analysisaccount-assetaccount-projects | Account details, rankings, holdings, resources, approvals, votes, analysis, assets, and participated projects. |
| Super Representative | 4 | srsr-votesparamsproposal | SR lists, voting details, chain parameters, and proposals. |
| Transaction | 10 | txtx-listtx-statstransfertransfer-statstransfer-trc20transfer-trc20-contracttransfer-trc1155transfer-trc721internal-tx | Transaction details, lists, statistics, transfers, and internal transactions. |
| Statistics | 20 | trx-supplytrx-turnoverprotocol-revenueburn-revenuestake-revenuetx-trendtx-totalactive-accountsnew-accountsdefi-tvltop10trx-priceenergy-dailyenergy-distenergy-costbandwidth-dailytrigger-statstoken-tvctoken-analysistoken-transfer-analysis | Supply, revenue, transactions, accounts, DeFi TVL, rankings, price, energy, bandwidth, contract triggers, and token analytics. |
| Contract | 9 | contractcontract-listcontract-callerscontract-energycontract-daily-callerscontract-daily-callscontract-analysiscontract-all-callerscontract-triggers | Contract details, lists, callers, energy usage, daily activity, analysis, and trigger transactions. |
| Security | 6 | security-accountsecurity-tokensecurity-urlsecurity-txsecurity-authsecurity-sign | Risk checks for accounts, tokens, URLs, transactions, approvals, and multisig settings. |
| Deep Analysis | 4 | deep-relateddeep-flowdeep-big-txdeep-token-transfer | Related accounts, fund flow, large transactions, and token transfer counts. |
| Stablecoin | 11 | stable-holdersstable-changestable-topstable-big-txstable-eventsstable-diststable-liquiditystable-poolstable-pool-trendstable-pool-changestable-tvl | Stablecoin holders, whale rankings, large transactions, events, distribution, liquidity, pools, and TVL. |
| Other | 1 | api | Call a TronScan API path directly. |
API Reference
See api-reference.md for the complete API endpoint list.
License
MIT
