TronApi 接口文档

TRON区块链API服务 · 生成钱包 · 查询余额 · 转账 · 助记词

Base URL:https://tronapi.net
TRX能量租用 TronApi Github 靓号生成 助记词转私钥
🔓 全部接口公开免费,无需注册即可调用。

📮 钱包

GET/api/address/generate生成新钱包

返回64位hex私钥和T开头钱包地址

curl https://tronapi.net/api/address/generate
{
  "success": true,
  "data": {
    "privatekey": "abc...",
    "wallet": "Txxx..."
  }
}
GET/api/mnemonic/generate生成12位助记词

生成BIP39标准12个英文助记词

curl https://tronapi.net/api/mnemonic/generate

返回:

{"success":true,"data":{"result":"成功","mnemonic":"word1 word2 ... word12"}}
POST/api/mnemonic/recover助记词恢复钱包

输入12个BIP39助记词,返回私钥和钱包地址

curl -X POST https://tronapi.net/api/mnemonic/recover \
  -H "Content-Type: application/json" \
  -d '{"mnemonic":"abandon ability able about above absent absorb abstract access accident account acquire"}'

返回:

{"success":true,"data":{"result":"成功","privatekey":"abc...","wallet":"Txxx..."}}
POST/api/mnemonic/to-private-key助记词→私钥

输入12个BIP39助记词,返回64位hex私钥

curl -X POST https://tronapi.net/api/mnemonic/to-private-key \
  -H "Content-Type: application/json" \
  -d '{"mnemonic":"word1 word2 ... word12"}'

返回:

{"success":true,"data":{"result":"成功","private_key":"64位hex私钥"}}
POST/api/address/from-private-key私钥→地址
curl -X POST https://tronapi.net/api/address/from-private-key \
  -H "Content-Type: application/json" \
  -d '{"private_key":"64位hex私钥"}'

💰 余额查询

POST/api/balance/trx查TRX余额
curl -X POST https://tronapi.net/api/balance/trx \
  -H "Content-Type: application/json" \
  -d '{"address":"TPhh7UeRf4h6SaU69RqQdRepT3sDHKVTUC"}'

返回:

{"success":true,"data":{"result":"成功","address":"Txxx...","balance":"163.331747","unit":"TRX"}}
POST/api/balance/trc20查USDT余额
curl -X POST https://tronapi.net/api/balance/trc20 \
  -H "Content-Type: application/json" \
  -d '{"address":"TPhh7UeRf4h6SaU69RqQdRepT3sDHKVTUC"}'

返回:

{"success":true,"data":{"result":"成功","address":"Txxx...","token":"USDT","balance":"8550.739694"}}

💸 转账

POST/api/transfer/trxTRX转账
curl -X POST https://tronapi.net/api/transfer/trx \
  -H "Content-Type: application/json" \
  -d '{
    "private_key":"你的64位私钥",
    "to":"收款T地址",
    "amount":100
  }'
参数说明
private_key64位hex私钥
to收款地址(T开头或41开头)
amount转账数量(TRX)

返回:

// 成功
{"success":true,"data":{"result":"成功","txID":"交易哈希..."}}
// 失败
{"success":false,"data":{"result":"失败","reason":"余额不足"}}
POST/api/transfer/trc20USDT转账
curl -X POST https://tronapi.net/api/transfer/trc20 \
  -H "Content-Type: application/json" \
  -d '{
    "private_key":"你的64位私钥",
    "to":"收款T地址",
    "amount":100
  }'
参数说明
private_key64位hex私钥
to收款地址(T开头或41开头)
amount转账数量(USDT)

返回:

// 成功
{"success":true,"data":{"result":"成功","txID":"交易哈希..."}}
// 失败
{"success":false,"data":{"result":"失败","reason":"余额不足"}}

📋 交易记录

POST/api/transaction/trc20USDT交易记录
curl -X POST https://tronapi.net/api/transaction/trc20 \
  -H "Content-Type: application/json" \
  -d '{"address":"TPhh7UeRf4h6SaU69RqQdRepT3sDHKVTUC","limit":50}'
POST/api/transaction/by-addressTRX交易记录
curl -X POST https://tronapi.net/api/transaction/by-address \
  -H "Content-Type: application/json" \
  -d '{"address":"TPhh7UeRf4h6SaU69RqQdRepT3sDHKVTUC","limit":50}'

💻 PHP 代码示例

PHP cURL使用cURL调用接口
<?php
// 生成钱包
$res = file_get_contents('https://tronapi.net/api/address/generate');
print_r(json_decode($res, true));

// 查余额
$ch = curl_init('https://tronapi.net/api/balance/trx');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'address' => 'TPhh7UeRf4h6SaU69RqQdRepT3sDHKVTUC'
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
print_r(json_decode(curl_exec($ch), true));