1. Introduction

The Order & Position Streaming API provides real-time streaming updates for:

The API uses a secure WebSocket (wss://) connection and pushes updates instantly whenever state changes occur in the trading system.

This API eliminates the need for polling and ensures low-latency state synchronization.


2. WebSocket Endpoint

wss://<baseurl>/realtime

Replace <baseurl> with the value returned from the /tradeApiValidate API.

Example:

wss://e21.kotaksecurities.com/realtime


3. Authentication & Connection Flow

Step 1: Open WebSocket Connection

const ws =newWebSocket(`wss://${baseurl}/realtime`);


Step 2: Send Connection Payload (MANDATORY)

Immediately after onopen, send authentication string:

{type:cn,Authorization:<token>,Sid:<sid>,src:WEB}