Skip to content

POST /apiv2/time/add

在主机模式下添加TRON地址以实现持续自动化的能量委托。

概述

时间添加端点注册一个TRON地址用于主机模式管理,启用自动的24小时能量委托周期。添加后,该地址将收到131,000个能量单位,这些单位将根据使用模式自动续期。

端点 URL

POST https://netts.io/apiv2/time/add

身份验证

此端点使用JSON主体身份验证(而非标头)。您的API密钥和目标地址在请求主体中提供。

请求头

HeaderRequiredDescription
Content-TypeYesapplication/json

请求体

json
{
    "api_key": "your_api_key",
    "address": "TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE"
}

参数

ParameterTypeRequiredValidationDescription
api_keystringYesMust exist in systemYour API key for authentication and billing
addressstringYesTRC-20 formatTRON address to add to Host Mode (must start with 'T' and be 34 characters)

参数验证

  • api_key: Must be a valid API key associated with your account and have sufficient balance
  • address: Must match TRC-20 format ^T[1-9A-HJ-NP-Za-km-z]{33}$
  • IP Address: Your request IP must be in the whitelist associated with your API key

示例请求

cURL

bash
curl -X POST https://netts.io/apiv2/time/add \
  -H "Content-Type: application/json" \
  -d '{
    "api_key": "YOUR_API_KEY_HERE",
    "address": "TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE"
  }'

Python

python
import requests

url = "https://netts.io/apiv2/time/add"
data = {
    "api_key": "YOUR_API_KEY_HERE", 
    "address": "TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE"
}

response = requests.post(url, json=data, verify=True)

if response.status_code == 200:
    result = response.json()
    if result['code'] == 0:
        print(f"✅ Address added successfully: {result['data']['address']}")
        print(f"Timestamp: {result['data']['timestamp']}")
    else:
        print(f"❌ Error: {result['msg']}")
else:
    print(f"HTTP Error: {response.status_code}")

Node.js

javascript
const axios = require('axios');

const url = 'https://netts.io/apiv2/time/add';
const data = {
    api_key: 'YOUR_API_KEY_HERE',
    address: 'TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE'
};

axios.post(url, data)
    .then(response => {
        const result = response.data;
        if (result.code === 0) {
            console.log(`✅ Address added: ${result.data.address}`);
        } else {
            console.log(`❌ Error: ${result.msg}`);
        }
    })
    .catch(error => {
        console.error('Request failed:', error.response?.data || error.message);
    });

响应

成功响应 (200 OK)

json
{
    "code": 0,
    "msg": "Address added to Host Mode successfully",
    "data": {
        "address": "TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE",
        "timestamp": "2025-09-02T07:30:15.123456"
    }
}

响应字段

FieldTypeDescription
codeintegerResponse code (0 = success, negative = error)
msgstringHuman-readable response message
data.addressstringThe TRON address that was added
data.timestampstringISO timestamp when address was added

错误响应

身份验证错误 (401)

json
{
    "code": -1,
    "msg": "Invalid API key or IP not in whitelist",
    "data": null
}

无效地址格式 (400)

json
{
    "code": -1,
    "msg": "Invalid TRC-20 address format",
    "data": null
}

地址已存在 (400)

json
{
    "code": -1,
    "msg": "This address is already managed in Host Mode",
    "data": null
}

数据库错误 (500)

json
{
    "code": -1,
    "msg": "Database error adding address",
    "data": null
}

内部服务器错误 (500)

json
{
    "code": -1,
    "msg": "Internal server error",
    "data": null
}

速率限制

以下速率限制适用于此端点(每个 IP 地址):

PeriodLimitDescription
1 second1 requestMaximum 1 request per second
1 minute60 requestsMaximum 60 requests per minute

速率限制报头

API在响应头中返回速率限制信息:

http
RateLimit-Limit: 1
RateLimit-Remaining: 0
RateLimit-Reset: 1
X-RateLimit-Limit-Second: 1
X-RateLimit-Remaining-Second: 0
X-RateLimit-Limit-Minute: 60
X-RateLimit-Remaining-Minute: 59
Retry-After: 1

速率限制已超出 (429)

json
{
    "message": "API rate limit exceeded"
}

When rate limit is exceeded, wait for the time specified in Retry-After header.

添加地址后会发生什么

  1. Database Registration: Address is registered in the Host Mode system
  2. Status Set: Address status is set to 0 (ready for activation)
  3. Cycle Mode: Address is set to infinity mode by default (cycle_set = 0)
  4. Ready for Energy: Address is now ready to receive automatic energy delegation

主机模式行为

一旦地址添加到主机模式:

  • Energy Amount: 131,000 energy units per delegation
  • Duration: 24 hours per delegation cycle
  • Auto-Renewal: Energy automatically renews when:
    • USDT transfer is detected (immediate reclaim + re-delegate)
    • 24 hours pass with no activity (automatic renewal)
  • Cycle Consumption: Each delegation consumes 1 cycle from your balance

安全与验证

地址验证

  • Format Check: Address must match TRC-20 format T[1-9A-HJ-NP-Za-km-z]{33}
  • Length Check: Exactly 34 characters
  • Duplicate Prevention: Cannot add the same address twice

身份验证安全

  • API Key Validation: Key must exist and be active
  • IP Whitelist: Request IP must be in your account's whitelist
  • User Verification: System validates both TG and normal users

数据库安全

  • Transaction Safety: Uses database transactions for consistency
  • Rollback Protection: Automatic rollback on errors
  • Connection Pooling: Secure connection management with HAProxy

技术细节

服务架构

  • Port: 9010
  • Framework: FastAPI with Pydantic models
  • Database: PostgreSQL with connection pooling
  • Load Balancing: HAProxy for read/write operations
  • Logging: Comprehensive logging to /path/to/your/logs/time_api.log

数据库操作

  • Table: netts_web_hosting_mode
  • Operation: INSERT new record
  • Default Values:
    • status = 0 (ready)
    • cycle_set = 0 (infinity mode)
  • Timestamps: Automatic created_at and updated_at

相关端点

添加地址后,您可以:

最佳实践

添加地址之前

  1. Verify Address: Double-check TRON address is correct and activated
  2. Check Balance: Ensure sufficient TRX balance for cycles
  3. IP Whitelist: Confirm your IP is whitelisted
  4. Test API Key: Verify API key works with other endpoints

添加地址后

  1. Monitor Status: Use Time Status endpoint to track cycles
  2. Set Cycles: Use Time Order to purchase specific cycles if needed
  3. Enable Infinity: Use Time Infinity Start for continuous operation
  4. Track Usage: Monitor your energy delegation cycles and costs

故障排除

常见问题

IssueCauseSolution
Authentication failedAPI key invalid or IP not whitelistedCheck API key and add IP to whitelist
Invalid address formatAddress doesn't match TRC-20 formatVerify address is 34 characters starting with 'T'
Address already existsTrying to add duplicate addressCheck existing addresses with Time Status
Database errorTemporary database issueRetry request after a few seconds

错误代码参考

CodeHTTP StatusDescriptionAction Required
0200SuccessNone - address added successfully
-1400/401/500Various errorsCheck error message for details

备注

  • Default Mode: Addresses are added in infinity mode by default (unlimited cycles)
  • Energy Delegation: System will begin managing energy for this address
  • Billing: Cycles are charged from your account balance automatically
  • Address Limit: Check your account limits for maximum addresses in Host Mode
  • Activation: Address should be activated on TRON network before adding
  • Monitoring: Use Time Status endpoint to monitor address performance