Skip to main content

Order Book WebSocket

Streams order book snapshots for a symbol whenever the book changes.

Event nameFETCH_ORDER_BOOK_CS_PRO
ConnectionSee Connection for handshake and namespace details.

Subscribe

import socketio

sio = socketio.Client()

BASE_URL = "wss://ws.coinswitch.co/"
NAMESPACE = "/coinswitchx" # exchange namespace
pair = "BTC,INR" # note BASE,QUOTE — comma, not slash

sio.connect(
url=BASE_URL,
namespaces=[NAMESPACE],
transports="websocket",
socketio_path="/pro/realtime-rates-socket/spot",
wait=True,
wait_timeout=3600,
)

sio.emit(
"FETCH_ORDER_BOOK_CS_PRO",
{"event": "subscribe", "pair": pair},
namespace=NAMESPACE,
)

@sio.on("FETCH_ORDER_BOOK_CS_PRO", namespace=NAMESPACE)
def on_order_book(data):
print("Order book update:", data)

sio.wait()

Update payload

{
"s": "BTC,INR",
"timestamp": 1673255767122,
"bids": [
["1471201.000000000000", "0.005870"],
["1470201.000000000000", "0.046770"]
],
"asks": [
["1484400.000000000000", "0.022109"],
["1484500.000000000000", "0.000390"]
]
}
FieldTypeDescription
sstringSymbol in BASE,QUOTE form.
timestampintegerSnapshot time (Unix ms).
bidsarraySorted descending. Each entry [price, quantity] (both strings).
asksarraySorted ascending. Each entry [price, quantity] (both strings).

Each push is a full snapshot, not a delta. Replace your local book on every event.