Get Real-Time Ticker Prices via WebSocket
This WebSocket API provides real-time updates for tickers on Nami Exchange.
Connection Information
Base URL:
wss://nfp-gateway.nami.exchangePath:
/ws/publicTransport: WebSocket
Data Format: JSON
Reconnection: Enabled with exponential backoff (recommended on the client side)
Connection
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 ticker updates for BTCUSDT
socket.send(JSON.stringify({
event: "subscribe",
data: {
channel: "nfp:ticker",
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.
2. Subscribe to Ticker
Event: subscribe
Description: Subscribes to real-time ticker updates for a specific trading pair.
Payload: JSON object
3. Receive Ticker Updates
Event: nfp:ticker
Description: Provides real-time ticker updates for the subscribed trading pair.
Payload: JSON object containing price and market metrics.
Disconnection & Reconnection
The WebSocket client automatically attempts to reconnect using exponential backoff.
If the connection is interrupted:
Reconnect indefinitely
After reconnecting, the client must resubscribe to the ticker channel
Notes
Subscribed symbols should be provided in lowercase (btcusdt), while the payload returns the symbol in uppercase (BTCUSDT).
The ticker stream is used for:
Real-time price display
Funding and mark price calculations
Data crawling for CoinGecko
Clients should throttle UI rendering due to the high frequency of updates.
Last updated