文档目录

批量处理 — API 参考

单个请求,批量交付多个接收地址。

方法路径概览
GET/v1/batches列出批次任务
POST/v1/batches单次调用为多个接收方批量下单
GET/v1/batches/{batchId}查询批次执行进度
POST/v1/batches/{batchId}/cancel取消批次中尚未开始的项

基于 openapi.yaml 在构建时生成。基准 URL 为 https://api.tenergy.me/v1,Nile 测试网环境为 https://api-nile.tenergy.me/v1(详见环境说明)。下述每个请求均遵循身份鉴权规范进行签名,除非鉴权行另有说明。

列出批次任务

GET /v1/batches · listBatches

鉴权: API 密钥 (HMAC)。

请求参数

参数名位置类型必选说明
limitqueryinteger
cursorquerystring上次响应中 next_cursor 返回的不透明游标。

响应

状态码含义
200OK
401缺少、格式错误或已被拒绝的凭据。
429请求过于频繁。
500服务端内部错误。

响应字段

字段类型必选说明
dataarray of object (Batch)是
data[].idstring是
data[].client_batch_idstring | null
data[].statusenum: queued, processing, completed, partial, failed, cancelled是批次状态。partial 表示部分接收地址成功交付而部分失败 —— 请检查 items,切勿假定全部成功或全部失败。
data[].items_acceptedinteger是
data[].summaryobject是各状态明细项统计。比拉取全部 items 更轻量。
data[].summary.totalinteger
data[].summary.queuedinteger
data[].summary.processinginteger
data[].summary.completedinteger
data[].summary.partialinteger
data[].summary.failedinteger
data[].summary.insufficient_fundsinteger
data[].summary.cancelledinteger
data[].itemsarray of object (BatchItem)是
data[].items[].receiverstring是Base58Check 编码的 TRON 地址(以 T 开头,34 个字符)。
data[].items[].tracking_idstring是<client_batch_id>:<receiver> —— 批次中每个接收方的唯一跟踪 ID。
data[].items[].statusenum: queued, processing, completed, partial, failed, insufficient_funds, cancelled是
data[].items[].resourceenum: energy, bandwidth, activationenergy —— TRON 能量。· bandwidth —— TRON 带宽。· activation —— 账户激活。
data[].items[].amountinteger
data[].items[].tierenum: 5m, 15m, 1h, 1d, 3d, 30d租赁周期。请通过 GET /v1/prices 实时获取。
data[].items[].delivered_amountinteger实际完成质押交付的数量。
data[].items[].order_idsarray of string为该接收方创建的底层订单 ID 列表。属于普通独立订单,可单独查询和提前回收。
data[].items[].delegate_hashesarray of string链上质押交易哈希列表。
data[].items[].charged_amount_suninteger (int64)扣费金额(以 SUN 为单位,1 TRX = 1,000,000 SUN)。始终为整数。
data[].items[].activationobject
data[].items[].bandwidthobject
data[].items[].attemptsinteger
data[].items[].started_atstring (date-time) | null
data[].items[].finished_atstring (date-time) | null
data[].items[].failurenull | object
data[].created_atstring (date-time)是
data[].finished_atstring (date-time) | null
next_cursorstring | null是

单次调用为多个接收方批量下单

POST /v1/batches · createBatch

鉴权: API 密钥 (HMAC)。

单个请求支持最多 100 个接收地址。对于每个地址,平台会自动串联完整交付流程 —— 若地址未激活则自动激活,若带宽不足则补充带宽,随后执行资源交付(大额自动分笔切片)。

接口返回 202 Accepted:批次已入队排队,此时尚未扣款且未完成质押交付。可通过 GET /v1/batches/{id} 或各订单的 Webhook 回调获取执行结果。

单个接收方失败不会影响其他接收方,激活或带宽补充步骤失败也不会阻断能量订单的主交付。

每个接收方按其实际执行时刻的实时价格进行计费结算。可通过设置每项的 max_price_sun 控制单价上限。

每个接收方会生成对应的独立订单 ID。client_batch_id 作为整批任务的幂等键:相同 ID 和请求体将返回原始批次;相同 ID 但不同请求体将拒绝并返回 3010 idempotency_conflict。

请求参数

参数名位置类型必选说明
Idempotency-Keyheaderstring客户端指定的安全重试幂等键(8–128 个字符 A-Z a-z 0-9 . _ : -)。记录保留 24 小时。

请求体

JSON (BatchRequest),必填。

字段类型必选说明
client_batch_idstring批次的自定义业务 ID 兼幂等键。若未提供 Idempotency-Key 请求头则此字段必填。
defaultsobject (BatchItemOptions)适用于批次中所有未单独覆盖对应字段的条目的默认配置。
defaults.resourceenum: energy, bandwidth, activationenergy, bandwidth 或 activation。
defaults.amountinteger
defaults.tierenum: 5m, 15m, 1h, 1d, 3d, 30d租赁周期。
defaults.activateboolean
defaults.bandwidthboolean在交付能量前,若接收方带宽不足则自动补充。
defaults.bandwidth_amountinteger补充的带宽数量。
defaults.max_price_suninteger (int64)最高可接受单价(SUN)。
defaults.client_order_id_prefixstring订单 ID 前缀,生成的订单 ID 为 "<prefix>-<receiver>",便于业务端对账。
itemsarray of object是接收方明细列表。同一批次中出现重复接收地址将返回 2006 duplicate_receiver。
items[].receiverstring是Base58Check 编码的 TRON 地址(以 T 开头,34 个字符)。
items[].resourceenum: energy, bandwidth, activation
items[].amountinteger
items[].tierenum: 5m, 15m, 1h, 1d, 3d, 30d
items[].activateboolean
items[].bandwidthboolean
items[].bandwidth_amountinteger
items[].max_price_suninteger (int64)
items[].client_order_id_prefixstring

来自规范的请求体示例(示意数值):

json
{
  "client_batch_id": "acme-payout-2026-09-11-01",
  "defaults": {
    "resource": "energy",
    "tier": "1h",
    "amount": 65000,
    "activate": true,
    "bandwidth": true,
    "bandwidth_amount": 400
  },
  "items": [
    {"receiver":"TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE"},
    {"receiver":"TXXxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","amount":131000},
    {"receiver":"TYYyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy","bandwidth":false}
  ]
}

响应

状态码含义
200相同的 client_batch_id 与请求体 —— 返回已有的原批次。
202批次已受理入队排队。尚未产生扣费。
400格式错误的请求 —— 无效 JSON、未知字段或字段类型错误。
401缺少、格式错误或已被拒绝的凭据。
402账户余额不足以支付批次订单。
409幂等冲突或对象状态冲突。
422语法合法但逻辑上无法满足操作要求。
429请求过于频繁。
500服务端内部错误。
503服务暂时不可用。

响应字段 (Batch)

字段类型必选说明
idstring是
client_batch_idstring | null
statusenum: queued, processing, completed, partial, failed, cancelled是批次执行状态。
items_acceptedinteger是
summaryobject是汇总统计信息。
summary.totalinteger
summary.queuedinteger
summary.processinginteger
summary.completedinteger
summary.partialinteger
summary.failedinteger
summary.insufficient_fundsinteger
summary.cancelledinteger
itemsarray of object (BatchItem)是
items[].receiverstring是Base58Check 编码的 TRON 地址(以 T 开头,34 个字符)。
items[].tracking_idstring是<client_batch_id>:<receiver>。
items[].statusenum: queued, processing, completed, partial, failed, insufficient_funds, cancelled是
items[].resourceenum: energy, bandwidth, activation
items[].amountinteger
items[].tierenum: 5m, 15m, 1h, 1d, 3d, 30d
items[].delivered_amountinteger
items[].order_idsarray of string生成的底层订单 ID 列表。
items[].delegate_hashesarray of string链上质押交易哈希。
items[].charged_amount_suninteger (int64)实际扣费金额(SUN)。
items[].activationobject
items[].activation.statusenum: planned, not_needed, done, failed, skipped
items[].activation.hashstring | null
items[].bandwidthobject
items[].bandwidth.statusenum: planned, enough, done, failed, skipped
items[].bandwidth.order_idstring | null
items[].bandwidth.skip_reasonenum: option_off, amount_large | null
items[].attemptsinteger
items[].started_atstring (date-time) | null
items[].finished_atstring (date-time) | null
items[].failurenull | object
items[].failure.codeinteger
items[].failure.slugstring
items[].failure.messagestring
created_atstring (date-time)是
finished_atstring (date-time) | null

查询批次执行进度

GET /v1/batches/{batchId} · getBatch

鉴权: API 密钥 (HMAC)。

请求参数

参数名位置类型必选说明
batchIdpathstring是平台批次 ID (bat_…) 或 cid:<client_batch_id>。
receiverquerystring可选过滤条件,仅返回指定地址的单项状态而非整个批次。

响应

状态码含义
200OK
401缺少、格式错误或已被拒绝的凭据。
404目标对象不存在或属于其他账户。
429请求过于频繁。
500服务端内部错误。

响应字段 (Batch)

字段结构与 POST /v1/batches 响应中的字段相同。

取消批次中尚未开始的项

POST /v1/batches/{batchId}/cancel · cancelBatch

鉴权: API 密钥 (HMAC)。

从排队队列中移除所有尚未开始处理的接收项。不会中断已经在处理中的项。

请求参数

参数名位置类型必选说明
batchIdpathstring是

响应

状态码含义
200OK
401缺少、格式错误或已被拒绝的凭据。
404目标对象不存在或属于其他账户。
429请求过于频繁。
500服务端内部错误。

响应字段

字段类型必选说明
idstring是
cancelledinteger是从队列中成功移除的条目数量。

    ↑ ↓ 切换 · Enter 打开 · Esc 关闭