Skip to content

POST /apiv2/time/add

Agregue una dirección TRON al Modo Host para la delegación continua y automatizada de energía.

Resumen

El punto final de agregar tiempo registra una dirección TRON para la administración del Modo Host, permitiendo ciclos automáticos de delegación de energía de 24 horas. Una vez agregada, la dirección recibirá 131,000 unidades de energía que se renuevan automáticamente en función de los patrones de uso.

URL del Punto Final

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

Autenticación

Este punto final utiliza autenticación mediante cuerpo JSON (no encabezados). Su clave API y la dirección de destino se proporcionan en el cuerpo de la solicitud.

Encabezados de la solicitud

HeaderRequiredDescription
Content-TypeYesapplication/json

Cuerpo de la solicitud

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

Parámetros

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)

Validación de Parámetros

  • 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

Ejemplos de Solicitudes

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);
    });

Respuesta

Respuesta exitosa (200 OK)

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

Campos de Respuesta

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

Respuestas de Error

Error de Autenticación (401)

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

Formato de Dirección No Válido (400)

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

Dirección ya existente (400)

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

Error de Base de Datos (500)

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

Error interno del servidor (500)

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

Límites de Tasa

Los siguientes límites de velocidad se aplican a este punto final (por dirección IP):

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

Encabezados de Límite de Tasa

La API devuelve información de limitación de velocidad en los encabezados de respuesta:

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

Límite de Tasa Superado (429)

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

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

Qué sucede después de agregar una dirección

  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

Comportamiento del Modo Anfitrión

Una vez que se agrega una dirección al Modo Host:

  • 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

Seguridad y Validación

Validación de Direcciones

  • 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

Seguridad de Autenticación

  • 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

Seguridad de la base de datos

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

Detalles técnicos

Arquitectura del Servicio

  • 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

Operaciones de Base de Datos

  • 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

Puntos Finales Relacionados

Después de agregar una dirección, puede:

Mejores Prácticas

Antes de agregar una dirección

  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

Después de agregar una dirección

  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

Solución de problemas

Problemas Comunes

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

Referencia de Códigos de Error

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

Notas

  • 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