面向开发者和企业的 TRON 能量 API
后台能做的一切,都可以通过代码完成:用 TRX 或 USDT 为余额充值,为任意地址购买能量或带宽,激活新地址,运行自动化。能量按 15 分钟或 1 小时租用,价格跟随我们的提供商,每笔一次性订单都包含固定订单费。每次交付只扣费一次,重试永远不会重复购买。交易所和支付处理商
在每次提现或归集充值之前购买能量,让 USDT 转账的成本只占原本需要燃烧的 TRX 的一小部分。热钱包
用 Auto-refill(自动补充)让地址始终有能量:每当能量低于您设定的阈值就自动补充,按每次交付计费。钱包和机器人
检查收款地址是否存在,必要时将其激活,并只购买一笔转账恰好需要的能量。快速开始
- 在后台的 API & Keys 中创建账户和 API 密钥,您还可以在那里设置 webhook 和 IP 白名单。
- 为余额充值:GET /account 会返回您的 TRX / USDT(TRC-20)充值地址。
- 使用 POST /orders 并附上唯一的 Idempotency-Key 购买能量,然后轮询 GET /orders/{id}。
接口列表
GET /docs本参考文档的 Markdown 版本,始终与已部署的 API 一致。
GET /prices当前价格和订单限制。
GET /prices/history1 小时能量价格的历史走势。
GET /account余额、用于充值的充值地址,以及该账户的价格。
GET /deposits充值地址收到的付款,按从新到旧排列。
POST /orders为任意 TRON 地址购买能量或带宽,从余额支付。
GET /orders该账户的订单,按从新到旧排列。
GET /orders/{id}单笔订单及其当前状态。
GET /addresses/{address}地址是否已在链上存在,以及激活它的费用。
POST /addresses/{address}/activate激活新地址,从余额支付。
GET /automations该账户的自动化(不含已删除的),按从新到旧排列。
POST /automations在地址上启动 Auto-refill(自动补充)、Auto-renewal(自动续期)或 Smart mode(智能模式)。
GET /automations/{id}单个自动化。
POST /automations/{id}/pause暂停自动化。
POST /automations/{id}/resume恢复已暂停的自动化。
DELETE /automations/{id}永久删除自动化。
GET /deliveries自动化完成的交付,按从新到旧排列,附每次的费用。
示例:购买能量并等待交付
javascriptconst API = 'https://getgas.io/api/v1';const headers = {Authorization: `Bearer ${process.env.GETGAS_API_KEY}`};async function buyEnergy(address, volume, term = '1h') {// One key per purchase: a retry after a timeout returns the same order instead of buying twice.const idempotencyKey = crypto.randomUUID();let order;for (let attempt = 0; attempt < 3 && !order; attempt++) {const res = await fetch(`${API}/orders`, {method: 'POST',headers: {...headers, 'Content-Type': 'application/json', 'Idempotency-Key': idempotencyKey},body: JSON.stringify({address, volume, term}),}).catch(() => null);if (!res) continue; // network error: retry with the same keyconst body = await res.json();if (!res.ok) throw new Error(`${body.error.code}: ${body.error.message}`);order = body.data;}if (!order) throw new Error('Could not reach the API');// Wait until the order is final.while (['pending', 'submitted', 'unknown'].includes(order.status)) {await new Promise(resolve => setTimeout(resolve, 3000));order = (await (await fetch(`${API}/orders/${order.id}`, {headers})).json()).data;}return order; // "filled", "refunded" or "failed"}