# User Information Endpoint
The /userinfo
endpoint provides detailed information about the authenticated user, including account details, balance, usage statistics, and network information.
# Endpoint URL
GET https://netts.io/apiv2/userinfo
# Authentication
This endpoint requires authentication via an API key. See the Authentication page for details.
# Request Headers
Header | Required | Description |
---|---|---|
X-API-KEY | Yes | Your NETTS API key |
X-Real-IP | Yes | IP address that is whitelisted for your API key |
Content-Type | No | application/json |
# IP Whitelist
All API requests must come from IP addresses that have been added to your whitelist. You can add up to 3 IP addresses to your whitelist on the dashboard page (opens new window).
# How to Add an IP to Your Whitelist
- Log in to your NETTS dashboard
- Navigate to the API tab: https://www.netts.io/workspace/dashboard.php?tab=api
- In the "IP Whitelist" section, click the "Add IP Address" button
- Enter a valid IPv4 or IPv6 address
- Confirm the addition
Note: Requests from IP addresses that are not included in your whitelist will be rejected with an authentication error.
# Response
The response includes user information, account statistics, and current network parameters.
# Response Parameters
Parameter | Type | Description |
---|---|---|
status | string | Request status ("success" or "error") |
timestamp | string | Response timestamp in "YYYY-MM-DD HH:MM:SS" format |
user_id | integer | User's unique identifier |
user_info | object | User's account information |
stats | object | User's statistics and usage data |
network_info | object | Current network parameters |
# User Info Object Structure
The user_info
object contains:
Parameter | Type | Description |
---|---|---|
string | User's email address | |
name | string | User's name |
# Stats Object Structure
The stats
object contains:
Parameter | Type | Description |
---|---|---|
balance | number | Current account balance in TRX |
total_delegations | integer | Total number of energy delegations |
total_energy_delegated | integer | Total amount of energy delegated |
total_trx_spent | number | Total amount of TRX spent on energy delegations |
total_deposit | number | Total amount deposited to the account in TRX |
avg_rate_sun_energy | number | Average rate in SUN per unit of energy |
save_by_netts_percent | number | Percentage saved by using NETTS compared to on-chain freezing |
save_in_dollars | number | Amount saved in USD by using NETTS |
# Network Info Object Structure
The network_info
object contains:
Parameter | Type | Description |
---|---|---|
trx_price | number | Current TRX price in USD |
network_energy_fee | number | Current network energy fee in TRX |
# Example Requests
# CURL Example
curl -X GET "https://netts.io/apiv2/userinfo" \
-H "Content-Type: application/json" \
-H "X-API-KEY: your_api_key" \
-H "X-Real-IP: your_whitelisted_ip"
# Python Example
import requests
import json
# Request configuration
url = "https://netts.io/apiv2/userinfo"
api_key = "your_api_key" # Your API key
headers = {
"Content-Type": "application/json",
"X-API-KEY": api_key,
"X-Real-IP": "your_whitelisted_ip" # IP from your whitelist
}
try:
# Send GET request to the userinfo API
response = requests.get(url, headers=headers, timeout=15)
# Process JSON response
if response.status_code == 200:
data = response.json()
print(json.dumps(data, ensure_ascii=False, indent=2))
# Print user information
user_info = data.get('user_info', {})
print(f"\nUser: {user_info.get('name')} ({user_info.get('email')})")
# Print statistics
stats = data.get('stats', {})
print(f"Balance: {stats.get('balance')} TRX")
print(f"Total Energy Delegated: {stats.get('total_energy_delegated')}")
print(f"Save by NETTS: {stats.get('save_by_netts_percent')}%")
else:
print(f"Error: {response.status_code}")
print(response.text)
except Exception as e:
print(f"An error occurred: {str(e)}")
# Example Response
{
"status": "success",
"timestamp": "2025-04-23 14:30:45",
"user_id": 12345,
"user_info": {
"email": "[email protected]",
"name": "Example User"
},
"stats": {
"balance": 150.25,
"total_delegations": 42,
"total_energy_delegated": 5502000,
"total_trx_spent": 235.75,
"total_deposit": 500.00,
"avg_rate_sun_energy": 425.32,
"save_by_netts_percent": 28.45,
"save_in_dollars": 12.35
},
"network_info": {
"trx_price": 0.0849,
"network_energy_fee": 0.000420
}
}
# Error Responses
Status Code | Description |
---|---|
401 | Authentication error (invalid API key or IP not in whitelist) |
403 | Access forbidden (IP address not added to whitelist) |
404 | User not found |
429 | Rate limit exceeded (too many requests) |
500 | Internal server error |
# Error Response Examples
{
"status": "error",
"code": -1,
"msg": "Invalid API key or IP not in whitelist"
}
{
"status": "error",
"code": -2,
"msg": "Your IP address is not whitelisted"
}
# Notes
- The
balance
field in the stats shows the current available balance for energy delegations. - The
total_deposit
field shows the total amount ever deposited to the account. - The
save_by_netts_percent
field shows how much the user is saving by using NETTS compared to freezing TRX directly on the TRON network. - The
avg_rate_sun_energy
is calculated as (total_trx_spent
/total_energy_delegated
) * 1,000,000. - All TRX amounts are shown with 2 decimal places.
- The TRX price is shown with 4 decimal places.
- The network energy fee is shown with 6 decimal places for precision.