Kotak Neo Market Data WebSocket — Developer Guide

A single WebSocket connection streams live market data (LTP, OHLC, depth, indices, market open/close). This guide is language-agnostic: any language with a WebSocket library and the ability to read little-endian binary data can implement a client.

It covers the native_batch protocol only. If you use the official Python SDK (kotakneoapi), all of the decoding below is done for you — read this when you’re building your own client in another language, or when you want to understand what the SDK does under the hood.


1. The mental model

One socket carries two planes:

Plane Frames Direction Used for
Control JSON text both ways auth, subscribe, unsubscribe, snapshot, acknowledgements
Data binary (little-endian, often batched) server → you the actual ticks

Three rules hold everywhere on the data plane:

Set your socket’s binary type to raw bytes (arraybuffer or your language’s equivalent) before reading data frames.

The happy path, end to end

  1. Connect — open the WebSocket.
  2. Authenticate — send one JSON frame the moment the socket opens.
  3. Store the dividers from the auth response (keyed by exchange). You need them to decode every price later.
  4. Subscribe — send a JSON frame naming the instrument and the data level you want.
  5. Receive a binary frame — treat it as a batch of packets.
  6. De-frame it into individual packets (§6.1).
  7. Route each packet by message_code / level (§6.2).