POST /apiv2/time/order
为指定地址购买指定数量的 Energy 代理周期并为其激活 Host Mode。
接口 URL
POST https://netts.io/apiv2/time/order身份验证
在请求体(api_key)或 X-API-KEY 请求头中提供您的 API 密钥。请求 IP 必须在为您 API 密钥配置的白名单中。
请求体
json
{
"api_key": "your_api_key",
"address": "TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE",
"cycles": 10
}参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| api_key | string | 是 | API 密钥(或 X-API-KEY 请求头)。 |
| address | string | 是 | TRON (TRC-20) 地址,^T[1-9A-HJ-NP-Za-km-z]{33}$。 |
| cycles | integer | 是 | 购买的周期数。必须 ≥ 1。 |
定价与计费
- 订购周期不会预先扣费。 每个周期在其 Energy 被代理的时刻进行计费:一次激活中的首次代理费用为 4 TRX,后续每次代理费用为 2 或 4 TRX,具体取决于您上一笔转账实际消耗的 Energy(≤65,000 → 2 TRX,更多 → 4 TRX)。有关完整规则(包括自 2026-08-29 起生效的 8 TRX 每日最低消费),请参阅 Host Mode → 周期与定价。
- 响应中的
amount是一个预估值(cycles × 参考价格),并非最终总额。 - 在接受订单前会检查您的余额;如果余额无法覆盖订单,订单将被拒绝(错误码
-2)。
提交订单会将该地址设置为激活(active)状态,并针对所请求的周期数创建一个未完成订单。随后,该地址开始按周期逐次接收 Energy 代理,每次代理在发生时进行扣费。
请求示例
cURL
bash
curl -X POST https://netts.io/apiv2/time/order \
-H "Content-Type: application/json" \
-d '{
"api_key": "YOUR_API_KEY_HERE",
"address": "TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE",
"cycles": 10
}'Python
python
import requests
resp = requests.post(
"https://netts.io/apiv2/time/order",
json={
"api_key": "YOUR_API_KEY_HERE",
"address": "TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE",
"cycles": 10,
},
timeout=30,
)
result = resp.json()
if result["code"] == 0:
d = result["data"]
print(f"Order {d['order_id']}: {d['cycles']} cycles for {d['amount']} TRX")
else:
print("Error:", result["msg"])Node.js
javascript
const axios = require('axios');
axios.post('https://netts.io/apiv2/time/order', {
api_key: 'YOUR_API_KEY_HERE',
address: 'TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE',
cycles: 10,
}).then(({ data: result }) => {
if (result.code === 0) {
const d = result.data;
console.log(`Order ${d.order_id}: ${d.cycles} cycles for ${d.amount} TRX`);
} else {
console.error('Error:', result.msg);
}
}).catch(err => console.error('Request failed:', err.response?.data || err.message));响应
成功 (200 OK)
json
{
"code": 0,
"msg": "Cycles purchased and host mode activated successfully",
"data": {
"order_id": 5426,
"address": "TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE",
"cycles": 10,
"amount": 23.5,
"status": "active",
"timestamp": "2026-07-13T05:30:15.123456"
}
}响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
| code | integer | 0 = 成功,负数 = 错误 |
| msg | string | 人类可读的消息 |
| data.order_id | integer | 内部订单标识符 |
| data.address | string | 购买周期的目标地址 |
| data.cycles | integer | 购买的周期数 |
| data.amount | number | 预估订单总额,单位为 TRX(仅供参考 —— 按每次代理实际计费) |
| data.status | string | 成功下单后为 "active" |
| data.timestamp | string | 订单的 ISO 时间戳 |
错误响应
| code | msg | 原因 |
|---|---|---|
| -1 | Invalid API key or IP not in whitelist | 身份验证失败 |
| -1 | Invalid TRC-20 address format | 地址格式错误 |
| -1 | Cycle count must be 1 or more | cycles < 1 |
| -1 | Database error processing order | 临时服务器端错误 — 请重试 |
| -2 | Insufficient balance. Required: X TRX, Available: Y TRX | 余额低于订单总额 |
| -6 | Cannot buy cycles: There is an open order with … cycles for this address | 已存在未完成的订单(包括无限模式) |
json
{
"code": -2,
"msg": "Insufficient balance. Required: 23.5 TRX, Available: 10.0 TRX"
}相关接口
- POST /apiv2/time/add — 先添加地址
- POST /apiv2/time/infinitystart — 开启无限周期而非固定数量
- POST /apiv2/time/status — 查看剩余周期
- POST /apiv2/time/stop — 停止并关闭订单
注意事项
- 如果地址尚未处于 Host Mode,订购时也会同时注册并激活它。
- 同一时间每个地址仅允许存在一个未完成订单。
- 购买的周期每次代理消耗一个;耗尽后地址将自动停止。