WebSocket API Reference

ການສົ່ງຂໍ້ມູນແບບ Real-time ສຳລັບ whale positions, funding rates, liquidations, ແລະ AI confirmation scores. ຄວາມຊ້ຳຊ່ອຍຕ່ຳກວ່າ 1 ວິນາທີ ພ້ອມການເຊື່ອມຕໍ່ຄືນໂດຍອັດຕະໂນມັດ, ການບີບອັດຂໍ້ມູນທີ່ມີປະສິດທິພາບ, ແລະການສະໝັກຫຼາຍສະຕີມ.

Overview

WebSocket API ຈັດຫາການສື່ສານສອງທາງທີ່ມີຄວາມຊ້ຳຊ່ອຍຕ່ຳສຳລັບຂໍ້ມູນ derivatives cryptocurrency ແບບ Real-time. ແທນທີ່ຈະ polling REST endpoints ທຸກໆ 5-30 ວິນາທີ, WebSocket connections ຈະສົ່ງການອັບເດດທັນທີເມື່ອສະພາບຕະຫຼາດປ່ຽນແປງ. ເໝາະສົມສຳລັບ trading bots, ລະບົບແຈ້ງເຕືອນ, ແລະ dashboards ແບບ Real-time.

ຂໍ້ດີຫຼັກຂອງ WebSocket ເມື່ອທຽບກັບ REST:

ຄວາມຊ້ຳຊ່ອຍຕ່ຳກວ່າ 1 ວິນາທີສຳລັບເຫດການທີ່ມີຜົນຕໍ່ຕະຫຼາດ (liquidations, whale moves)
ການໃຊ້ bandwidth ທີ່ມີປະສິດທິພາບດ້ວຍການອັບເດດແບບ delta-encoded
ການສະໝັກຫຼາຍສະຕີມພ້ອມກັນໃນການເຊື່ອມຕໍ່ດຽວ
ການກັ່ນຕອງແລະການລວມຂໍ້ມູນທາງ server-side
ການຈັດການ heartbeat ແລະການເຊື່ອມຕໍ່ຄືນໂດຍອັດຕະໂນມັດ
ຈຳນວນຄຳຮ້ອງຂໍ API ທີ່ໃຊ້ໃນ quota ທີ່ຕ່ຳກວ່າ
ການເຊື່ອມຕໍ່ WebSocket ມີໃຫ້ທຸກລະດັບ API. ຜູ້ໃຊ້ແບບຟຣີສາມາດສະໝັກສະຕີມ funding-rates ແລະ liquidations. ລະດັບ Trader ແລະ Pro ຈະເປີດໃຊ້ whale positions, open interest, ແລະ confirmation scores.

Authentication

ການເຊື່ອມຕໍ່ WebSocket ໃຊ້ການຢືນຢັນຄືກັນກັບ REST endpoints. ສົ່ງ API key ຂອງທ່ານເປັນ query parameter ຫຼືສົ່ງໃນຂໍ້ຄວາມທຳອິດຫຼັງຈາກເຊື່ອມຕໍ່.

Connection URL

Base WebSocket URL: wss://ws.smartmoneyapi.com/stream

ລວມ API key ຂອງທ່ານໃນ URL ການເຊື່ອມຕໍ່:

URL
wss://ws.smartmoneyapi.com/stream?token=sk_live_abc123xyz789

Connection Lifecycle

Initial Connection

ເມື່ອທ່ານເຊື່ອມຕໍ່ກັບ WebSocket endpoint, server ຈະກວດສອບ authentication token ແລະສົ່ງການຍອມຮັບການເຊື່ອມຕໍ່.

Server Response (JSON)
{ "type": "connection_ack", "connection_id": "conn_1a2b3c4d5e6f7g8h", "server_version": "1.2.4", "timestamp": "2026-03-21T14:35:22Z", "api_tier": "pro", "max_subscriptions": 50, "max_symbols_per_sub": 100 }

Heartbeat (Ping/Pong)

Server ຈະສົ່ງ ping heartbeat ເປັນປະຈຳທຸກໆ 30 ວິນາທີ. Client ຂອງທ່ານຕ້ອງຕອບກັບຂໍ້ຄວາມ pong ເພື່ອຮັກສາການເຊື່ອມຕໍ່ໃຫ້ຍັງຄົງຢູ່. ຖ້າ server ບໍ່ໄດ້ຮັບການຕອບ pong ພາຍໃນ 10 ວິນາທີ, ການເຊື່ອມຕໍ່ຈະຖືກປິດ.

JavaScript
const ws = new WebSocket("wss://ws.smartmoneyapi.com/stream?token=sk_live_abc123xyz789"); ws.onmessage = (event) => { const msg = JSON.parse(event.data); if (msg.type === "ping") { // Respond to ping with pong ws.send(JSON.stringify({ type: "pong", id: msg.id })); } }; ws.onopen = () => { console.log("Connected to WebSocket"); };

Subscriptions

ຫຼັງຈາກເຊື່ອມຕໍ່, ສະໝັກສະຕີມຂໍ້ມູນໂດຍໃຊ້ຂໍ້ຄວາມສະໝັກ. ແຕ່ລະການສະໝັກຈະສ້າງການອັບເດດເມື່ອຂໍ້ມູນຕະຫຼາດປ່ຽນແປງ.

Subscription Message Format

JSON
{ "type": "subscribe", "channel": "whale_positions", "symbols": ["BTCUSDT", "ETHUSDT"], "params": { "min_position_size": 10, "exchanges": ["bybit", "binance"] } }

Unsubscribe Message Format

JSON
{ "type": "unsubscribe", "channel": "whale_positions", "symbols": ["BTCUSDT"] }

Whale Positions Stream

ການອັບເດດ Real-time ສຳລັບ whale positions ຂະໜາດໃຫຍ່ໃນທຸກໆ symbols ແລະ exchanges ທີ່ຕິດຕາມ. ຈະສົ່ງການອັບເດດເມື່ອ whales ເປີດ, ປິດ, ຫຼືແກ້ໄຂ positions. ລວມມີ entry price, ລາຄາປັດຈຸບັນ, P&L, leverage, ແລະຄວາມສ່ຽງການ liquidation.

JSON — Subscribe
{ "type": "subscribe", "channel": "whale_positions", "symbols": ["BTCUSDT", "ETHUSDT", "SOLUSDT"] }

Update Message

JSON — Update
{ "type": "data", "channel": "whale_positions", "symbol": "BTCUSDT", "data": { "wallet_address": "0x1234...", "exchange": "bybit", "direction": "long", "position_size": 25.3, "entry_price": 41200.0, "current_price": 43200.5, "pnl": 50701.50, "pnl_percent": 4.86, "leverage": 8, "liquidation_price": 33760.0, "timestamp": "2026-03-21T14:35:45Z" } }

Funding Rates Stream

ການອັບເດດ funding rate ແບບ Real-time ທົ່ວ Bybit, Binance, ແລະ Hyperliquid. ອັບເດດທຸກໆ 1 ນາທີ ຫຼືເມື່ອ rates ປ່ຽນແປງຢ່າງຫຼວງຫຼາຍ. ລວມມີ rates ຂອງແຕ່ລະ exchange ແລະຕົວຊີ້ວັດທີ່ຖືກລວມ.

JSON — Subscribe
{ "type": "subscribe", "channel": "funding_rates", "symbols": ["BTCUSDT", "ETHUSDT"] }

Update Message

JSON — Update
{ "type": "data", "channel": "funding_rates", "symbol": "BTCUSDT", "data": { "timestamp": "2026-03-21T14:00:00Z", "bybit": { "rate": 0.000120, "next_rate": 0.000145 }, "binance": { "rate": 0.000098, "next_rate": 0.000115 }, "hyperliquid": { "rate": 0.000140, "next_rate": 0.000160 }, "aggregated": { "mean": 0.000119, "median": 0.000120, "spread": 0.000062 } } }

Liquidations Stream

ຟີດ liquidations ແບບ Real-time ທີ່ສະແດງການປິດ positions ທີ່ໃຊ້ leverage ແບບບັງຄັບ. ລວມມີຂະໜາດ position, ລາຄາ liquidation, ທິດທາງ (long/short), ແລະ exchange. ເປັນປະໂຫຍດໃນການຈຳແນກ liquidation cascades ແລະການເຄື່ອນໄຫວຂອງຕະຫຼາດທີ່ມີຜົນກະທົບສູງ.

JSON — Subscribe
{ "type": "subscribe", "channel": "liquidations", "params": { "min_size_usd": 50000 } }

Update Message

JSON — Update
{ "type": "data", "channel": "liquidations", "data": { "exchange": "binance", "symbol": "BTCUSDT", "direction": "long", "position_size": 12.5, "liquidation_price": 41000.0, "size_usd": 512500.0, "timestamp": "2026-03-21T14:35:12Z" } }

Open Interest Stream

Open Interest ທີ່ຖືກລວມສຳລັບຜູ້ຄ້າ leverage ທັງໝົດໃນແຕ່ລະ symbol. ຕິດຕາມການເພີ່ມຂຶ້ນຂອງ OI (ເງິນເຂົ້າສູ່ leverage ຫຼາຍຂຶ້ນ) ແລະການຫຼຸດລົງ (positions ກຳລັງປິດ). ຄວາມແຕກຕ່າງຂອງ OI ຈາກການເຄື່ອນໄຫວຂອງລາຄາຈະຊ່ວຍຈຳແນກຄວາມອິດເມື່ອຍທີ່ເຊື່ອງຢູ່ (bullish/bearish exhaustion).

JSON — Subscribe
{ "type": "subscribe", "channel": "open_interest", "symbols": ["BTCUSDT", "ETHUSDT"] }

Confirmation Scores Stream

ຄະແນນ AI confirmation ແບບ Real-time ທີ່ລວມ whale positions, ສັນຍານ on-chain, funding rates, ແລະຂໍ້ມູນ sentiment. ຄະແນນຈະອັບເດດເມື່ອສັນຍານພື້ນຖານປ່ຽນແປງ, ໃຫ້ສັນຍານການເຂົ້າ/ອອກທີ່ແທ້ຈິງສຳລັບ algorithm ການຊື້ຂາຍ.

JSON — Subscribe
{ "type": "subscribe", "channel": "confirmation_scores", "symbols": ["BTCUSDT", "ETHUSDT", "SOLUSDT"] }

Automatic Reconnection Logic

ບັນຫາເຄືອຂ່າຍ ຫຼືການບຳລຸງຮັກສາ server ອາດຈະເຮັດໃຫ້ການເຊື່ອມຕໍ່ຂາດ. ຈັດຕັ້ງລະບົບ exponential backoff reconnection ເພື່ອຟື້ນຟູຈາກຄວາມລົ້ມເຫຼວໂດຍອັດຕະໂນມັດ ໂດຍຄຳນຶງເຖິງພາລະຂອງ server.

Recommended Reconnection Strategy

JavaScript
class SmartMoneyWebSocket { constructor(token, options = {}) { this.token = token; this.maxReconnectDelay = options.maxReconnectDelay || 30000; this.reconnectDelay = 1000; this.subscriptions = new Map(); this.connect(); } connect() { this.ws = new WebSocket( `wss://ws.smartmoneyapi.com/stream?token=${this.token}` ); this.ws.onopen = () => { console.log("Connected"); this.reconnectDelay = 1000; // Reset backoff this.resubscribe(); // Re-subscribe after reconnect }; this.ws.onmessage = (event) => { const msg = JSON.parse(event.data); if (msg.type === "ping") { this.ws.send(JSON.stringify({ type: "pong", id: msg.id })); } this.onMessage(msg); }; this.ws.onclose = () => this.reconnect(); this.ws.onerror = (err) => console.error("WebSocket error:", err); } reconnect() { console.log(`Reconnecting in ${this.reconnectDelay}ms`); setTimeout(() => { this.connect(); this.reconnectDelay = Math.min( this.reconnectDelay * 1.5, this.maxReconnectDelay ); }, this.reconnectDelay); } subscribe(channel, symbols, params) { const key = `${channel}:${symbols.join(",")}`; this.subscriptions.set(key, { channel, symbols, params }); this.ws.send(JSON.stringify({ type: "subscribe", channel, symbols, params })); } resubscribe() { for (const { channel, symbols, params } of this.subscriptions.values()) { this.ws.send(JSON.stringify({ type: "subscribe", channel, symbols, params })); } } onMessage(msg) { if (msg.type === "data") { console.log(`Update: ${msg.channel}/${msg.symbol}`, msg.data); } } } const client = new SmartMoneyWebSocket("sk_live_abc123xyz789"); client.subscribe("whale_positions", ["BTCUSDT", "ETHUSDT"]); client.subscribe("funding_rates", ["BTCUSDT"]); client.subscribe("liquidations", [], { min_size_usd: 100000 });

Code Examples

Python WebSocket Client

Python
import asyncio import json import websockets async def stream_whale_positions(): uri = "wss://ws.smartmoneyapi.com/stream?token=sk_live_abc123xyz789" async with websockets.connect(uri) as websocket: # Wait for connection ack ack = await websocket.recv() print(f"Connected: {ack}") # Subscribe to whale positions await websocket.send(json.dumps({ "type": "subscribe", "channel": "whale_positions", "symbols": ["BTCUSDT", "ETHUSDT"] })) # Listen for updates while True: try: msg = await websocket.recv() data = json.loads(msg) if data["type"] == "ping": # Respond to ping await websocket.send(json.dumps({ "type": "pong", "id": data["id"] })) elif data["type"] == "data": print(f"New position: {data['data']}") except websockets.exceptions.ConnectionClosed: print("Connection closed, reconnecting...") await asyncio.sleep(1) asyncio.run(stream_whale_positions())

Performance Tips

Filter on subscribe: ໃຊ້ params object ເພື່ອກັ່ນຕອງຂໍ້ມູນທາງ server-side (min_position_size, min_size_usd) ແທນທີ່ຈະກັ່ນຕອງໃນແອັບພລິເຄຊັນຂອງທ່ານ.
Batch subscriptions: ສະໝັກຫຼາຍ symbols ໃນຂໍ້ຄວາມດຽວ ແທນທີ່ຈະສະໝັກແຕ່ລະ symbol ແຍກກັນ.
Unsubscribe unused: ເມື່ອທ່ານບໍ່ຕ້ອງການສະຕີມແລ້ວ, ຍົກເລີກການສະໝັກເພື່ອປະຢັດ bandwidth ແລະຫຼຸດປະລິມານຂໍ້ຄວາມ.
Use gzip compression: ເປີດໃຊ້ການບີບອັດຂໍ້ຄວາມໃນ WebSocket client ຂອງທ່ານເພື່ອປະຢັດ bandwidth (ຫຼຸດລົງ 20-40%).
Monitor connection health: ຕິດຕາມ ping/pong latency ແລະການເຊື່ອມຕໍ່ຄືນໂດຍອັດຕະໂນມັດເພື່ອວິນິດໄສບັນຫາເຄືອຂ່າຍ.
Buffer messages during disconnection: ເມື່ອການເຊື່ອມຕໍ່ຂາດ, ຈັດລຽງຄິວສັນຍານຍຸດທະສາດ ແລະດຳເນີນການເມື່ອເຊື່ອມຕໍ່ຄືນ.

Start Streaming Now

ເອົາ API key ຂອງທ່ານ ແລະ ເລີ່ມສ້າງລະບົບການຊື້ຂາຍແບບ real-time. WebSocket streaming ມີໃຫ້ໃຊ້ໄດ້ໃນທຸກແບບ.

ເອົາ API Key

ສ້າງລະບົບການຊື້ຂາຍແບບ Real-Time

ສົ່ງຕໍ່ຂໍ້ມູນຕຳແໜ່ງ whale, ອັດຕາ funding, ແລະ ຄະແນນຢືນຢັນ AI ດ້ວຍ latency ໜ້ອຍກວ່າ 1 ວິນາທີ.

ເບິ່ງແຜນການ
ເລີ່ມຟຣີ - 100 ຄຳສັ່ງ/ມື້, ບໍ່ຕ້ອງໃຊ້ບັດ

ເອົາຂໍ້ມູນ whale flow, funding, open interest ແລະ ຂໍ້ມູນ on-chain ແບບ real-time ຈາກ 3 ແລກປ່ຽນຜ່ານ API ດຽວ. ເລີ່ມຟຣີ, ບໍ່ຕ້ອງໃຊ້ບັດ, ອັບເກຣດໄດ້ທຸກເວລາ.

ເລີ່ມຟຣີ →
ລອງໃຊ້ API console ແບບ real-time → (ບໍ່ຕ້ອງມີບັນຊີ)
ເອົາ API key ຂອງທ່ານໃນ 30 ວິນາທີ

ພ້ອມສ້າງແລ້ວບໍ? ເອົາ API key ຟຣີ (100 ຄຳສັ່ງ/ມື້, ບໍ່ຕ້ອງໃຊ້ບັດ) ແລະ ເລີ່ມດຶງຂໍ້ມູນ whale, funding ແລະ on-chain ແບບ real-time.

ເອົາ API key ຂອງທ່ານ →