POST /apiv2/subusergen
สร้างผู้ใช้ SUB (บัญชีย่อย) ใหม่ที่เชื่อมโยงกับบัญชีหลักของคุณ ผู้ใช้ SUB จะมี API key ที่อยู่ฝากเงิน และยอดคงเหลือแยกต่างหากสำหรับการดำเนินการด้าน Energy อย่างเป็นอิสระ
URL ของ Endpoint
POST https://netts.io/apiv2/subusergenHeaders ของคำขอ
| Header | Required | Description |
|---|---|---|
| Content-Type | Yes | application/json |
| X-API-KEY | Yes | API key ของคุณจากแดชบอร์ด Netts |
| X-Real-IP | Yes | ที่อยู่ IP จากไวท์ลิสต์ของคุณ |
เนื้อหาคำขอ
json
{}ไม่จำเป็นต้องระบุพารามิเตอร์ ผู้ใช้ SUB จะเชื่อมโยงกับบัญชีที่ระบุโดย API key โดยอัตโนมัติ
Examples การร้องขอ
cURL
bash
curl -X POST https://netts.io/apiv2/subusergen \
-H "Content-Type: application/json" \
-H "X-API-KEY: your_api_key" \
-H "X-Real-IP: your_whitelisted_ip" \
-d '{}'Python
python
import requests
url = "https://netts.io/apiv2/subusergen"
headers = {
"Content-Type": "application/json",
"X-API-KEY": "your_api_key",
"X-Real-IP": "your_whitelisted_ip"
}
response = requests.post(url, headers=headers, json={})
data = response.json()
if response.status_code == 200:
print(f"SUB User ID: {data['user_id']}")
print(f"Google ID: {data['google_id']}")
print(f"Email: {data['email']}")
print(f"Deposit Address: {data['deposit_address']}")
print(f"API Key: {data['api_key']}")
print(f"Referral Code: {data['referral_code']}")
print(f"Parent User ID: {data['referrer_user_id']}")
else:
print(f"Error: {data.get('detail', 'Unknown error')}")Node.js
javascript
const axios = require('axios');
async function createSubUser(apiKey, whitelistedIp) {
const url = 'https://netts.io/apiv2/subusergen';
const response = await axios.post(url, {}, {
headers: {
'Content-Type': 'application/json',
'X-API-KEY': apiKey,
'X-Real-IP': whitelistedIp
},
timeout: 30000
});
const data = response.data;
console.log(`SUB User ID: ${data.user_id}`);
console.log(`API Key: ${data.api_key}`);
console.log(`Deposit Address: ${data.deposit_address}`);
return data;
}
// Usage
createSubUser('your_api_key', 'your_whitelisted_ip')
.then(result => console.log('Created:', result))
.catch(err => console.error('Error:', err.response?.data || err.message));PHP
php
<?php
$url = 'https://netts.io/apiv2/subusergen';
$options = [
'http' => [
'header' => implode("\r\n", [
"Content-Type: application/json",
"X-API-KEY: your_api_key",
"X-Real-IP: your_whitelisted_ip"
]),
'method' => 'POST',
'content' => '{}',
'timeout' => 30
]
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
$data = json_decode($response, true);
echo "SUB User ID: {$data['user_id']}\n";
echo "API Key: {$data['api_key']}\n";
echo "Deposit Address: {$data['deposit_address']}\n";
?>การตอบกลับ
การตอบกลับเมื่อสำเร็จ (200 OK)
json
{
"user_id": 1379,
"google_id": "SUB123456789012345678",
"email": "[email protected]",
"name": "SUB123456789012345678",
"deposit_address": "TExampleAddress1234567890123456789",
"api_key": "mock1234567890abcdef1234567890ab",
"referral_code": "A2B4K9",
"created_at": "2026-03-14T12:00:00",
"referrer_user_id": 42,
"comment": "SUB user linked to main user (referrer_user_id). Google ID, Email and Name are mock data (not real) that can be updated via separate endpoint. For API services usage, requests must include this SUB user's API key and IP from main user's whitelist. Calculations use SUB user's balance. Generated deposit address is not active."
}ฟิลด์การตอบกลับ
| Field | Type | Description |
|---|---|---|
| user_id | integer | ID เฉพาะของผู้ใช้ SUB ที่สร้างขึ้น |
| google_id | string | ตัวระบุจำลอง (รูปแบบ: SUB + ตัวเลข 18 หลัก) ไม่ใช่บัญชี Google จริง — ใช้สำหรับการระบุตัวตนภายในของผู้ใช้ SUB เท่านั้น |
| string | อีเมลจำลอง (google_id + @gmail.com) ไม่ใช่ที่อยู่อีเมลจริง — ใช้สำหรับการระบุตัวตนภายในเท่านั้น | |
| name | string | ชื่อที่แสดง (ค่าเริ่มต้นเป็น google_id) สามารถเปลี่ยนแปลงได้ในแดชบอร์ด |
| deposit_address | string | ที่อยู่ฝากเงิน TRON ที่สร้างขึ้น (ไม่ได้เปิดใช้งานตามค่าเริ่มต้น) |
| api_key | string | API key สำหรับผู้ใช้ SUB (คำนำหน้า: mock) |
| referral_code | string | รหัสแนะนำที่สร้างขึ้น (6 ตัวอักษร) |
| created_at | string | การประทับเวลาที่สร้างในรูปแบบ ISO 8601 |
| referrer_user_id | integer | ID ผู้ใช้หลัก (บัญชีที่สร้างผู้ใช้ SUB นี้) |
| comment | string | คำแนะนำการใช้งานและหมายเหตุ |
ข้อมูล Google จำลอง
ฟิลด์ google_id, email, และ name เป็นข้อมูลจำลอง — ไม่ใช่บัญชี Google หรือที่อยู่อีเมลจริง ฟิลด์เหล่านี้มีไว้เพื่อการระบุตัวตนภายในของผู้ใช้ SUB ภายในระบบเท่านั้น ชื่อ และ แท็ก ของผู้ใช้ SUB สามารถเปลี่ยนแปลงได้ใน แดชบอร์ด
วิธีการทำงานของผู้ใช้ SUB
แนวคิดหลัก
- แยกยอดคงเหลือ: ผู้ใช้ SUB แต่ละรายจะมียอดคงเหลือ TRX ของตนเองแยกเป็นอิสระจากบัญชีหลัก
- ใช้ไวท์ลิสต์ IP ร่วมกัน: คำขอ API ของผู้ใช้ SUB จะได้รับการตรวจสอบกับไวท์ลิสต์ IP ของบัญชีหลัก
- มี API key ของตนเอง: ผู้ใช้ SUB แต่ละรายจะได้รับ API key เฉพาะสำหรับการยืนยันตัวตน
- เชื่อมโยงกับบัญชีหลัก: ผู้ใช้ SUB จะเชื่อมโยงกับบัญชีที่สร้างอย่างถาวรผ่านระบบการแนะนำ
- ใช้งานได้ทุก API endpoint: ผู้ใช้ SUB สามารถใช้ API endpoint ทั้งหมดได้ (order1h, time/order ฯลฯ) ด้วย API key และยอดคงเหลือของตนเอง
ขั้นตอนการใช้งาน
- สร้างผู้ใช้ SUB ผ่าน endpoint นี้
- เติมเงินให้ผู้ใช้ SUB โดยการฝาก TRX ไปยังที่อยู่ฝากเงิน หรือโอนยอดคงเหลือ
- ใช้ API key ของผู้ใช้ SUB ในคำขอ API ถัดไป (order1h, time/order ฯลฯ)
- ตรวจสอบ ผ่าน endpoint userinfo โดยใช้ API key ของผู้ใช้ SUB
การตอบกลับเมื่อเกิดข้อผิดพลาด
ข้อผิดพลาดในการยืนยันตัวตน (401)
json
{
"detail": "X-API-KEY header required"
}ถูกปฏิเสธการเข้าถึง (403)
json
{
"detail": "Invalid API key or IP not whitelisted"
}ข้อผิดพลาดในการตรวจสอบความถูกต้อง (422)
json
{
"detail": [...],
"body": {...}
}ข้อผิดพลาดภายในเซิร์ฟเวอร์ (500)
json
{
"detail": "Failed to create mock user: ..."
}ข้อมูลอ้างอิงรหัสข้อผิดพลาด
| HTTP Status | Description |
|---|---|
200 | สร้างผู้ใช้ SUB สำเร็จ |
401 | ไม่มีส่วนหัว API key |
403 | API key ไม่ถูกต้องหรือ IP ไม่อยู่ในไวท์ลิสต์ |
422 | ข้อผิดพลาดในการตรวจสอบความถูกต้องของคำขอ |
500 | ข้อผิดพลาดภายในเซิร์ฟเวอร์ |
หมายเหตุ
- ต้องมี Request Body ที่ว่างเปล่า
{}(Content-Type ต้องเป็น application/json) - ที่อยู่ฝากเงินที่สร้างขึ้นจะไม่เปิดใช้งานตามค่าเริ่มต้น
google_idและemailของผู้ใช้ SUB เป็นข้อมูลจำลอง (ไม่ใช่บัญชี Google จริง) ซึ่งใช้สำหรับการระบุตัวตนภายในเท่านั้น- ชื่อและแท็กของผู้ใช้ SUB สามารถเปลี่ยนแปลงได้ใน แดชบอร์ด
- API key ของผู้ใช้ SUB จะขึ้นต้นด้วยคำนำหน้า
mock - การตรวจสอบไวท์ลิสต์ IP จะใช้ไวท์ลิสต์ของผู้ใช้หลัก
- ผู้ใช้ SUB แต่ละรายจะมียอดคงเหลือของตนเอง แยกจากบัญชีหลัก
- ผู้ใช้ SUB สามารถลบได้ผ่าน endpoint DELETE /apiv2/subuserdel
- สามารถเปลี่ยนที่อยู่ฝากเงินได้ผ่าน endpoint POST /apiv2/address/rotate