OPENAPI 3.1.0
HTTPS · JSON
BEARER AUTH
Ship Xu Tự Động Open API
Tài liệu lập trình chuẩn OpenAPI 3.1 dùng cho tích hợp hệ thống tự động, bot đặt đơn và kết nối web con Ship Xu.
Xác thực API Key (Bearer Token)
Đăng nhập tài khoản để lấy API Key cá nhân và dùng tính năng Gọi thử cho các endpoint cần xác thực.
Đăng nhập
Quy trình đặt đơn chuẩn & quy tắc an toàn
01
Kiểm tra luồng & Báo giá
Gọi GET public_capacity + GET quote (kèm Bearer) để lấy đúng quote.total_vnd theo cấp bậc.
02
Sinh request_key 32 hex
Tạo và lưu request_key ([0-9a-f]{32}) trong DB của bạn trước khi gọi POST create để chống tạo đơn trùng.
03
Timeout 15 giây lấy mã phòng
Quá 15 giây không nhận được mã phòng, hệ thống tự hủy giữ chỗ và trả HTTP 409 (reason: "server_busy"), không trừ tiền ví.
04
Đối soát khi gián đoạn mạng
Nếu kết nối bị ngắt bất ngờ, gọi GET history&reconcile=1&request_key=... để biết chắc đơn đã tạo hay đã hủy.
GET
/api/ship-xu.php?action=catalog
Public
Danh mục máy chủ & gói Xu
Trả về danh sách máy chủ đang mở, đơn giá chuẩn, các gói Đơn Thường (4M–20M), Đơn Lớn/Login (10M–1B) và trạng thái nhận đơn.
Tham số yêu cầu
Phản hồi (Response Schema)
200
429
{
"servers": [
{
"id": 1,
"name": "Tiêu chuẩn",
"mode": "standard",
"enabled": true,
"price_per_million": 4000,
"ordering_available": true
}
],
"packages": [4, 8, 12, 16, 20],
"large_packages": {
"minimum": 10,
"maximum": 1000,
"presets": [10, 20, 50, 100, 500, 1000],
"ordering_available": true
},
"ordering_available": true
}
{
"error": "rate_limited"
}
cURL
PHP
JavaScript
Python
Sao chép
curl -s "https://hzstore.vn/api/ship-xu.php?action=catalog" \
-H "Accept: application/json"
$ch = curl_init('https://hzstore.vn/api/ship-xu.php?action=catalog');
curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 10]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
const res = await fetch('https://hzstore.vn/api/ship-xu.php?action=catalog');
const data = await res.json();
console.log(data.servers, data.ordering_available);
import requests
res = requests.get('https://hzstore.vn/api/ship-xu.php', params={'action': 'catalog'}, timeout=10)
print(res.json())
Gọi thử trực tiếp (Try it out)
GET
/api/ship-xu.php?action=public_capacity
Public
Kiểm tra số luồng trống
Kiểm tra số luồng Auto-Radar còn trống của Server 1 hoặc Server 2 trước khi gọi tạo đơn (giới hạn 120 req/phút/IP).
Tham số yêu cầu
Phản hồi (Response Schema)
200
429
{
"remaining_threads": 12,
"stale": false
}
{
"error": "rate_limited"
}
cURL
PHP
JavaScript
Python
Sao chép
curl -s "https://hzstore.vn/api/ship-xu.php?action=public_capacity&server_id=1"
$res = file_get_contents('https://hzstore.vn/api/ship-xu.php?action=public_capacity&server_id=1');
$cap = json_decode($res, true);
const res = await fetch('https://hzstore.vn/api/ship-xu.php?action=public_capacity&server_id=1');
console.log(await res.json());
import requests
print(requests.get('https://hzstore.vn/api/ship-xu.php', params={'action': 'public_capacity', 'server_id': 1}, timeout=10).json())
Gọi thử trực tiếp (Try it out)
GET
/api/ship-xu.php?action=quote
Tùy chọn Bearer
Báo giá đơn hàng
Lấy tổng tiền chính xác (quote.total_vnd) để truyền vào create. Gửi thêm Bearer để tự động áp dụng chiết khấu CTV / Đại lý.
Tham số yêu cầu
Phản hồi (Response Schema)
200
409
422
{
"quote": {
"server_id": 1,
"server_name": "Tiêu chuẩn",
"mode": "standard",
"amount_millions": 4,
"price_per_million": 4000,
"total_vnd": 16000,
"server_accepts_orders": true
},
"ordering_available": true
}
{
"error": "server_unavailable"
}
{
"error": "invalid_package_or_server"
}
cURL
PHP
JavaScript
Python
Sao chép
curl -s "https://hzstore.vn/api/ship-xu.php?action=quote&server_id=1&amount_millions=4&mode=standard" \
-H "Authorization: Bearer YOUR_API_KEY"
$ch = curl_init('https://hzstore.vn/api/ship-xu.php?action=quote&server_id=1&amount_millions=4');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY'],
CURLOPT_TIMEOUT => 10,
]);
$quote = json_decode(curl_exec($ch), true);
curl_close($ch);
const res = await fetch('https://hzstore.vn/api/ship-xu.php?action=quote&server_id=1&amount_millions=4', {
headers: { Authorization: 'Bearer YOUR_API_KEY' }
});
console.log(await res.json());
import requests
res = requests.get(
'https://hzstore.vn/api/ship-xu.php',
params={'action': 'quote', 'server_id': 1, 'amount_millions': 4},
headers={'Authorization': 'Bearer YOUR_API_KEY'},
timeout=10,
)
print(res.json())
Gọi thử trực tiếp (Try it out)
POST
/api/ship-xu.php?action=create
Bearer Auth
Tạo đơn Ship Xu
Khóa giá theo total_vnd từ quote và chống tạo trùng bằng request_key (32 ký tự hex). Với Đơn Thường, hệ thống lấy mã phòng tối đa 15 giây ; quá 15 giây chưa có mã phòng sẽ tự hủy giữ chỗ và trả HTTP 409 (reason: "server_busy"), ví chưa bị trừ tiền.
Tham số yêu cầu
Phản hồi (Response Schema)
201
409
422
{
"order": {
"order_code": "DH_A1B2C3D4",
"status": "processing",
"payment_state": "paid",
"room_id": "987654"
},
"replayed": false,
"radar_dispatch": "confirmed",
"balance": 247436,
"held_balance": 0,
"available_balance": 247436,
"next_request_key": "fedcba9876543210fedcba9876543210"
}
{
"error": "order_creation_failed",
"reason": "server_busy",
"next_request_key": "a1b2c3d4e5f60718293a4b5c6d7e8f90"
}
{
"error": "invalid_order"
}
cURL
PHP
JavaScript
Python
Sao chép
curl -s -X POST "https://hzstore.vn/api/ship-xu.php?action=create" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d "server_id=1&amount_millions=4&total_vnd=16000" \
-d "request_key=0123456789abcdef0123456789abcdef&guide_acknowledged=1"
$requestKey = bin2hex(random_bytes(16));
$ch = curl_init('https://hzstore.vn/api/ship-xu.php?action=create');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 20,
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY'],
CURLOPT_POSTFIELDS => http_build_query([
'server_id' => 1,
'amount_millions' => 4,
'total_vnd' => 16000,
'request_key' => $requestKey,
'guide_acknowledged' => '1',
]),
]);
$result = json_decode(curl_exec($ch), true);
curl_close($ch);
const body = new URLSearchParams({
server_id: '1',
amount_millions: '4',
total_vnd: '16000',
request_key: '0123456789abcdef0123456789abcdef',
guide_acknowledged: '1',
});
const res = await fetch('https://hzstore.vn/api/ship-xu.php?action=create', {
method: 'POST',
headers: { Authorization: 'Bearer YOUR_API_KEY' },
body,
});
console.log(res.status, await res.json());
import secrets, requests
res = requests.post(
'https://hzstore.vn/api/ship-xu.php?action=create',
headers={'Authorization': 'Bearer YOUR_API_KEY'},
data={
'server_id': 1, 'amount_millions': 4, 'total_vnd': 16000,
'request_key': secrets.token_hex(16), 'guide_acknowledged': '1',
},
timeout=20,
)
print(res.status_code, res.json())
GET
/api/ship-xu.php?action=history
Bearer Auth
Lịch sử đơn hàng & số dư ví
Trả về danh sách đơn thuộc tài khoản hiện tại kèm tiến độ giao Xu, mã phòng còn hiệu lực, Match ID, phân trang con trỏ (next_cursor) và số dư ví.
Tham số yêu cầu
Phản hồi (Response Schema)
200
401
{
"orders": [
{
"id": 1024,
"order_code": "DH_A1B2C3D4",
"server_name": "Tiêu chuẩn",
"amount_millions": 4,
"delivered_millions": 4,
"total_vnd": 16000,
"status": "completed",
"payment_state": "paid",
"room_id": null,
"created_at": "2026-12-01 14:30:00"
}
],
"next_cursor": null,
"wallet": {
"balance": 247436,
"held_balance": 0,
"available_balance": 247436
}
}
{
"error": "login_required"
}
cURL
PHP
JavaScript
Python
Sao chép
curl -s "https://hzstore.vn/api/ship-xu.php?action=history&limit=10" \
-H "Authorization: Bearer YOUR_API_KEY"
$ch = curl_init('https://hzstore.vn/api/ship-xu.php?action=history&limit=10');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY'],
]);
$orders = json_decode(curl_exec($ch), true);
curl_close($ch);
const res = await fetch('https://hzstore.vn/api/ship-xu.php?action=history&limit=10', {
headers: { Authorization: 'Bearer YOUR_API_KEY' }
});
console.log(await res.json());
import requests
res = requests.get(
'https://hzstore.vn/api/ship-xu.php',
params={'action': 'history', 'limit': 10},
headers={'Authorization': 'Bearer YOUR_API_KEY'},
timeout=10,
)
print(res.json())
Gọi thử trực tiếp (Try it out)
GET
/api/ship-xu.php?action=history&reconcile=1
Bearer Auth
Đối soát chi tiết 1 đơn hàng
Truyền đúng 1 trong 2 tham số code hoặc request_key để kiểm tra kết quả cuối cùng của đơn (dùng sau khi mạng lỗi/timeout hoặc đồng bộ web con).
Tham số yêu cầu
Phản hồi (Response Schema)
200
404
409
{
"order": {
"order_code": "DH_A1B2C3D4",
"server_id": 1,
"amount_millions": 4,
"delivered_millions": 4,
"total_vnd": 16000,
"status": "completed",
"payment_state": "paid",
"accepted": true,
"room_id": null,
"room_expires_in": 0,
"phase": 8,
"match_id": "MATCH-98765",
"settled": true,
"needs_review": false
}
}
{
"error": "order_not_found"
}
{
"error": "order_creation_failed",
"reason": "server_busy"
}
cURL
PHP
JavaScript
Python
Sao chép
curl -s "https://hzstore.vn/api/ship-xu.php?action=history&reconcile=1&code=DH_A1B2C3D4" \
-H "Authorization: Bearer YOUR_API_KEY"
$url = 'https://hzstore.vn/api/ship-xu.php?action=history&reconcile=1&code=' . rawurlencode('DH_A1B2C3D4');
$ch = curl_init($url);
curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY']]);
$snap = json_decode(curl_exec($ch), true);
curl_close($ch);
const res = await fetch('https://hzstore.vn/api/ship-xu.php?action=history&reconcile=1&code=DH_A1B2C3D4', {
headers: { Authorization: 'Bearer YOUR_API_KEY' }
});
console.log(res.status, await res.json());
import requests
res = requests.get(
'https://hzstore.vn/api/ship-xu.php',
params={'action': 'history', 'reconcile': 1, 'code': 'DH_A1B2C3D4'},
headers={'Authorization': 'Bearer YOUR_API_KEY'},
timeout=10,
)
print(res.status_code, res.json())
Gọi thử trực tiếp (Try it out)
GET
/api/profile.php
Bearer Auth
Thông tin tài khoản & số dư ví
Kiểm tra nhanh username và số dư money hiện tại của tài khoản sở hữu API Key.
Tham số yêu cầu
Endpoint này không cần tham số đầu vào (chỉ cần header Authorization: Bearer).
Phản hồi (Response Schema)
200
401
{
"status": "success",
"msg": "Lấy dữ liệu thành công!",
"data": [
{
"username": "tai_khoan_mau",
"money": "263436"
}
]
}
{
"status": "error",
"msg": "API key không hợp lệ"
}
cURL
PHP
JavaScript
Python
Sao chép
curl -s "https://hzstore.vn/api/profile.php" \
-H "Authorization: Bearer YOUR_API_KEY"
$ch = curl_init('https://hzstore.vn/api/profile.php');
curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY']]);
$profile = json_decode(curl_exec($ch), true);
curl_close($ch);
const res = await fetch('https://hzstore.vn/api/profile.php', {
headers: { Authorization: 'Bearer YOUR_API_KEY' }
});
console.log(await res.json());
import requests
print(requests.get('https://hzstore.vn/api/profile.php', headers={'Authorization': 'Bearer YOUR_API_KEY'}, timeout=10).json())
Gọi thử trực tiếp (Try it out)
GET
/api/ship-xu.php?action=capacity
Admin / Web con
Công suất chi tiết (Admin / Web con)
Trả về thông số công suất máy chủ chi tiết dành riêng cho quản trị viên hoặc tài khoản web con đã khai báo trong SHIP_XU_CHILD_USER_IDS ở .env web mẹ.
Tham số yêu cầu
Phản hồi (Response Schema)
200
401
503
{
"capacity": {
"Remaining_threads": 12,
"Remaining_devices": 8,
"running": 4
},
"updated_at": "2026-12-01T08:00:00+00:00",
"stale": false
}
{
"error": "login_required"
}
{
"error": "capacity_unavailable"
}
cURL
PHP
JavaScript
Python
Sao chép
curl -s "https://hzstore.vn/api/ship-xu.php?action=capacity&server_id=1" \
-H "Authorization: Bearer CHILD_OR_ADMIN_API_KEY"
$ch = curl_init('https://hzstore.vn/api/ship-xu.php?action=capacity&server_id=1');
curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ['Authorization: Bearer CHILD_OR_ADMIN_API_KEY']]);
$cap = json_decode(curl_exec($ch), true);
curl_close($ch);
const res = await fetch('https://hzstore.vn/api/ship-xu.php?action=capacity&server_id=1', {
headers: { Authorization: 'Bearer CHILD_OR_ADMIN_API_KEY' }
});
console.log(await res.json());
import requests
print(requests.get('https://hzstore.vn/api/ship-xu.php', params={'action': 'capacity', 'server_id': 1}, headers={'Authorization': 'Bearer CHILD_OR_ADMIN_API_KEY'}, timeout=10).json())
Mã lỗi HTTP, trạng thái đơn & giới hạn tần suất
Trạng thái đơn (status): pending · processing · completed · failed · refunded. |
Trạng thái tiền (payment_state): held (tạm giữ) · paid (đã trừ ví) · released (đã nhả giữ chỗ).
Webhook Web mẹ → Web con (HMAC-SHA256)
Khi web mẹ nhận cập nhật trạng thái đơn từ VNMOD, web mẹ sẽ đẩy sự kiện POST tới /api/ship-xu.php?action=parent_webhook của web con kèm header chữ ký X-Ship-Signature được ký bằng HMAC-SHA256 trên raw JSON body và kiểm tra bằng hash_equals().
// Header xác thực từ web mẹ:
X-Ship-Signature: <hex(hmac_sha256(raw_body, SHIP_XU_PARENT_WEBHOOK_SECRET))>
// Quy tắc kiểm tra phía web con:
$expected = hash_hmac('sha256', $rawBody, $_ENV['SHIP_XU_PARENT_WEBHOOK_SECRET']);
if (!hash_equals($expected, $_SERVER['HTTP_X_SHIP_SIGNATURE'] ?? '')) {
http_response_code(401);
exit;
}