Get Market Depth
This WebSocket API provides real-time order book depth updates on Nami Exchange.
Get Real Time Spot Depth By WebSocket
Overview This WebSocket API provides real-time order book depth updates on Nami Exchange.
Base URL:
wss://stream-asia2.nami.exchangePath:
/wsTransport: WebSocket
Reconnection: Enabled with exponential backoff
Connection To establish a connection, use the following WebSocket client configuration:
const socket = socketIO("https://stream-asia2.nami.exchange", {
path: "/ws",
upgrade: false,
reconnection: true,
reconnectionDelay: 100,
reconnectionDelayMax: 500,
reconnectionAttempts: Infinity,
transports: ["websocket"],
});Events
1. Connect
Event:
connectDescription: Triggered when the client successfully connects to the WebSocket server.
Example:
socket.on("connect", () => { console.log("Connected to WebSocket server"); });
2. Subscribe to Market Depth
Event:
subscribe:depthDescription: Subscribes to real-time order book depth updates for a specific trading pair.
Payload:
string(trading pair, e.g.,"BTCUSDT")Example:
socket.emit("subscribe:depth", "BTCUSDT");
3. Receive Market Depth Updates
Event:
spot:depth:updateDescription: Provides real-time order book depth updates for the subscribed trading pair.
Payload: JSON object containing bid and ask order book data.
Example Response:
{ "symbol": "BTCUSDT", "bids": [ [ 97638.22, 2.66402 ], [ 97638.2, 0.00018 ] ], "asks": [ [ 97638.23, 1.9828 ], [ 97638.27, 0.00018 ] ] }
Response Fields:
symbol
string
Trading pair (e.g., BTCUSDT)
bids
array
List of bid prices and quantities
asks
array
List of ask prices and quantities
Example Handling:
socket.on("spot:depth:update", (data) => { console.log("Order book update:", data); });
Disconnection & Reconnection
The WebSocket client automatically attempts to reconnect with exponential backoff.
If disconnected, it will retry indefinitely with a delay between 100ms - 500ms.
Notes
Ensure your WebSocket client supports reconnection strategies to maintain a stable connection.
Data is subject to market fluctuations and should be handled accordingly.
Last updated