Messages
{
"action": "auth",
"api_key": "your_api_key",
"signature": "a3f9c2d1e8b74c8d6e5f4a3b2c1d0e9f8a7b6c5d4e3f2a1b0c9d8e7f6a5b4c3d",
"timestamp": 1750000000,
"nonce": "1750000000123456"
}{
"action": "pong"
}{
"action": "unsubscribe",
"channels": [
{
"name": "tick.G1.json",
"symbols": [
"ACB"
]
}
]
}{
"action": "subscribe",
"channels": [
{
"name": "tick.G1.json",
"symbols": [
"ACB",
"HPG"
]
}
]
}{
"action": "welcome",
"session_id": "conn_1782199800969809263",
"timestamp": 1750000000,
"message": "Please authenticate within 30 seconds"
}{
"action": "auth_success",
"user_id": "your_api_key",
"capabilities": {
"batch_delivery": false
},
"rate_limit": {
"messages_per_second": 100,
"subscriptions_max": 100
}
}{
"action": "ping",
"timestamp": 1750000000123
}{
"action": "subscribed"
}{
"action": "unsubscribed"
}{
"action": "error",
"code": "AUTH_FAILED",
"message": "authentication failed: invalid signature"
}{
"action": "connection_expired",
"code": "MAX_DURATION_EXCEEDED",
"message": "Connection expired after 8 hours. Please reconnect."
}Websockets
Luồng điều khiển kết nối
Client thực hiện flow điều khiển theo thứ tự:
- Server gửi
welcomesau khi kết nối. - Client gửi
authvà chờauth_success. - Client gửi
subscribehoặcunsubscribeđể quản lý các channel dữ liệu. - Server có thể gửi
ping; client phản hồi bằngpong. - Client xử lý các phản hồi
subscribed,unsubscribed,errorvàconnection_expired.
WSS
/
v1
/
stream
Messages
{
"action": "auth",
"api_key": "your_api_key",
"signature": "a3f9c2d1e8b74c8d6e5f4a3b2c1d0e9f8a7b6c5d4e3f2a1b0c9d8e7f6a5b4c3d",
"timestamp": 1750000000,
"nonce": "1750000000123456"
}{
"action": "pong"
}{
"action": "unsubscribe",
"channels": [
{
"name": "tick.G1.json",
"symbols": [
"ACB"
]
}
]
}{
"action": "subscribe",
"channels": [
{
"name": "tick.G1.json",
"symbols": [
"ACB",
"HPG"
]
}
]
}{
"action": "welcome",
"session_id": "conn_1782199800969809263",
"timestamp": 1750000000,
"message": "Please authenticate within 30 seconds"
}{
"action": "auth_success",
"user_id": "your_api_key",
"capabilities": {
"batch_delivery": false
},
"rate_limit": {
"messages_per_second": 100,
"subscriptions_max": 100
}
}{
"action": "ping",
"timestamp": 1750000000123
}{
"action": "subscribed"
}{
"action": "unsubscribed"
}{
"action": "error",
"code": "AUTH_FAILED",
"message": "authentication failed: invalid signature"
}{
"action": "connection_expired",
"code": "MAX_DURATION_EXCEEDED",
"message": "Connection expired after 8 hours. Please reconnect."
}method
type:string
GET
query
type:object
encoding
type:string
bắt buộc
Định dạng mã hóa dữ liệu WebSocket (json, msgpack).
Yêu cầu xác thực WebSocket
type:object
Xác thực kết nối bằng API key và chữ ký HMAC-SHA256.
Phản hồi heartbeat
type:object
Client gửi pong để duy trì kết nối WebSocket.
Yêu cầu hủy đăng ký
type:object
Client yêu cầu hủy đăng ký một hoặc nhiều channel dữ liệu.
Yêu cầu đăng ký
type:object
Client yêu cầu đăng ký một hoặc nhiều channel dữ liệu.
Welcome message
type:object
Message server gửi sau khi kết nối WebSocket thành công.
Xác thực thành công
type:object
Message server gửi sau khi xác thực kết nối thành công.
Ping heartbeat
type:object
Message server gửi để kiểm tra kết nối WebSocket.
Đăng ký thành công
type:object
Server xác nhận client đã đăng ký channel dữ liệu.
Hủy đăng ký thành công
type:object
Server xác nhận client đã hủy đăng ký channel dữ liệu.
Lỗi điều khiển
type:object
Server gửi lỗi điều khiển trong quá trình kết nối hoặc đăng ký.
Kết nối hết hạn
type:object
Server thông báo kết nối đạt giới hạn thời gian và yêu cầu reconnect.