Depth (Order Book) Stream
Streams order book updates. Each message is a full snapshot of the top-of-book — replace your local copy on every event.
| Subject (all markets) | v1.f.public.futures.depth-update.> |
| Subject (one market) | v1.f.public.futures.depth-update.BTC/USDT |
| Auth | Public — no signature. |
Subscribe
- Python
- Java
- Go
- Node.js
import asyncio
import nats
async def main():
nc = await nats.connect("wss://pc-nats-prod.coinswitch.co")
sub = await nc.subscribe("v1.f.public.futures.depth-update.BTC/USDT")
async for msg in sub.messages:
print(msg.data.decode())
asyncio.run(main())
// implementation 'io.nats:jnats:2.17.4' on Maven Central.
import io.nats.client.*;
Connection nc = Nats.connect("wss://pc-nats-prod.coinswitch.co");
Dispatcher d = nc.createDispatcher(msg -> {
System.out.println(new String(msg.getData()));
});
d.subscribe("v1.f.public.futures.depth-update.BTC/USDT");
Thread.currentThread().join(); // block forever
import (
"log"
"github.com/nats-io/nats.go"
)
nc, err := nats.Connect("wss://pc-nats-prod.coinswitch.co")
if err != nil { log.Fatal(err) }
defer nc.Drain()
_, err = nc.Subscribe("v1.f.public.futures.depth-update.BTC/USDT", func(m *nats.Msg) {
log.Println(string(m.Data))
})
if err != nil { log.Fatal(err) }
select {}
// npm install nats
const { connect, StringCodec } = require('nats');
const nc = await connect({ servers: 'wss://pc-nats-prod.coinswitch.co' });
const sc = StringCodec();
const sub = nc.subscribe('v1.f.public.futures.depth-update.BTC/USDT');
for await (const m of sub) {
console.log(sc.decode(m.data));
}
Update payload — single market
{
"t": 1756475722086,
"m": "SUPER/USDT",
"b": [
["0.5777", "9"],
["0.5776", "1946"]
],
"a": [
["0.5781", "775"],
["0.5782", "3613"]
],
"e": "COINSWITCHX",
"E": 1756475722084
}
Update payload — wildcard
When you subscribe with the wildcard (...depth-update.>), each message is an array of one or more depth updates batched together. Process each entry independently against your local books.
Fields
| Field | Type | Description |
|---|---|---|
t | integer | System timestamp (Unix ms). |
E | integer | Exchange-side timestamp (Unix ms). |
m | string | Market — BASE/QUOTE. |
b | array | Bids. Each entry [price, quantity], both strings. Sorted descending. |
a | array | Asks. Each entry [price, quantity]. Sorted ascending. |
e | string | Exchange identifier. |