Get Market depth information

This WebSocket API provides real-time order book (market depth) updates for trading pairs on NAO Futures Plus – Nami Exchange.

Overview

This WebSocket API provides real-time updates of recent trading data on Nami Exchange.

  • Base URL: wss://nfp-gateway.nami.exchange

  • Path: /ws/public

  • Protocol: WebSocket

  • Reconnection: Enabled with exponential backoff

Connection

To establish a connection, use the following WebSocket client configuration:

const WS_URL = "wss://nfp-gateway.nami.exchange/ws/public?t=" + Date.now();
let socket;

function connect() {
  socket = new WebSocket(WS_URL);

  socket.onopen = () => {
    console.log("Connected to the WebSocket server");

    // Subscribe to order book for BTCUSDT
    socket.send(JSON.stringify({
      event: "subscribe",
      data: {
        channel: "nfp:depth",
        params: ["btcusdt"]
      }
    }));
  };

  socket.onmessage = (event) => {
    const data = JSON.parse(event.data);
    console.log("Received data:", data);
  };

  socket.onclose = () => {
    console.log("Connection closed, attempting to reconnect...");
    setTimeout(connect, 300);
  };

  socket.onerror = () => {
    socket.close();
  };
}

connect();

Events

1. Connection

  • Event: open

  • Description: Triggered when the client successfully connects to the WebSocket server.

Example:

2. Subscribe to Order Book (Depth)

  • Event: subscribe

  • Description: Subscribes to real-time order book updates for a specific trading pair.

  • Payload: JSON object

Example:

3. Receive Order Book Updates

  • Event: nfp:depth

  • Description: Provides real-time order book updates for the subscribed trading pair.

  • Payload: JSON object containing bid/ask levels and update metadata.

Response Example (actual):

Disconnection & Reconnection

  • The WebSocket client should automatically reconnect when the connection is lost.

  • Using exponential backoff is recommended (100ms → 500ms → 1000ms …).

  • After reconnecting, the client must resubscribe to all previously used channels.


Notes

  • Subscribed symbols should be provided in lowercase (btcusdt), while the payload returns the symbol in uppercase (BTCUSDT).

  • Order book data changes frequently; clients should:

    • Throttle UI rendering

    • Apply updates using firstUpdateId / finalUpdateId

  • In case of desynchronization, clients should reload a fresh snapshot from the REST API /price/depth.

Last updated