Whether it's fetching live market data or receiving instant trade confirmations, real-time streaming support greatly enhances the experience for traders and investors.
The 5paisa Xstream WebSocket API allows seamless integration of real-time data feeds into trading applications with minimal latency.
- π Live Streaming of Market Data: Access real-time price movements, quotes, and market depth.
- π Order & Trade Confirmations: Get immediate updates on all order lifecycle events (Place, Modify, Cancel, Trigger).
- π Secure & Authenticated Access: Requires valid
access_tokenandclient_code.
Use the following URL with query parameters:
wss://openfeed.5paisa.com/feeds/api/chat?Value1=<access_token>|<client_code>
- Replace
<access_token>and<client_code>with your credentials (from the access token API).
Once connected, the client sends subscription requests to receive specific types of data (market feed, depth, trade confirmations, etc.).
Clients can send Subscribe or Unsubscribe operations dynamically throughout the session.
- When the client sends
PING, the server responds withPONG. - Ensures the connection remains alive.
All messages are JSON objects with this structure:
{
"Method": "<method_name>",
"Operation": "Subscribe | Unsubscribe",
"ClientCode": "<client_code>",
"MarketFeedData": [
{
"Exch": "N",
"ExchType": "C",
"ScripCode": 1660
}
]
}| Method | Purpose |
|---|---|
MarketFeedV3 |
Real-time LTP, OHLC, bid/offer details |
MarketFeedLite |
Minimal quote data (LTP, % change, last qty) |
MarketDepthService |
Order book (bid/ask) depth |
GetScripInfoForFuture |
Open interest & OI high/low for derivatives |
OrderTradeConfirmations |
Order lifecycle updates (placed, traded, SL) |
- Purpose: Real-time quotes, LTP, OHLC, bid/ask
{
"Method": "MarketFeedV3",
"Operation": "Subscribe",
"ClientCode": "<client_code>",
"MarketFeedData": [
{"Exch": "N", "ExchType": "C", "ScripCode": 1660}
]
}{
"Method": "MarketFeedV3",
"Operation": "Unsubscribe",
"ClientCode": "<client_code>",
"MarketFeedData": [
{"Exch": "N", "ExchType": "C", "ScripCode": 1660}
]
}{
"Exch": "N",
"ExchType": "C",
"Token": 1660,
"LastRate": 440.1,
"TotalQty": 1000,
"High": 445.5,
"Low": 435.1,
"OpenRate": 438,
"PClose": 440,
"AvgRate": 441.2,
"Time": 35950,
"TickDt": "/Date(1718052145000)/"
}- Purpose: Lightweight version of MarketFeedV3 for minimal bandwidth use
{
"Method": "MarketFeedLite",
"Operation": "Subscribe",
"ClientCode": "<client_code>",
"MarketFeedData": [
{"Exch": "N", "ExchType": "C", "ScripCode": 1333},
{"Exch": "N", "ExchType": "D", "ScripCode": 148108},
{"Exch": "B", "ExchType": "C", "ScripCode": 500112}
]
}{
"Method": "MarketFeedLite",
"Operation": "Unsubscribe",
"ClientCode": "<client_code>",
"MarketFeedData": [
{"Exch": "N", "ExchType": "C", "ScripCode": 1333}
]
}{
"Exch": "N",
"ExchType": "C",
"Token": 1333,
"LastRate": 523.8,
"LastQty": 10,
"TickDt": "/Date(1718052145000)/",
"ChgPcnt": 0.45
}- Purpose: Order book depth (bid/ask levels)
{
"Method": "MarketDepthService",
"Operation": "Subscribe",
"ClientCode": "<client_code>",
"MarketFeedData": [
{"Exch": "N", "ExchType": "C", "ScripCode": 2885}
]
}{
"Method": "MarketDepthService",
"Operation": "Unsubscribe",
"ClientCode": "<client_code>",
"MarketFeedData": [
{"Exch": "N", "ExchType": "C", "ScripCode": 2885}
]
}{
"Exch": "N",
"ExchType": "C",
"Token": 2885,
"TBidQ": 75000,
"TOffQ": 82000,
"Details": [
{"Quantity": 500, "Price": 350.5, "NumberOfOrders": 3, "BbBuySellFlag": 66},
{"Quantity": 450, "Price": 350.6, "NumberOfOrders": 2, "BbBuySellFlag": 83}
],
"Time": "/Date(1718052145000)/"
}- Purpose: Real-time Open Interest (OI) info
{
"Method": "GetScripInfoForFuture",
"Operation": "Subscribe",
"ClientCode": "<client_code>",
"MarketFeedData": [
{"Exch": "N", "ExchType": "D", "ScripCode": 48508}
]
}{
"Method": "GetScripInfoForFuture",
"Operation": "Unsubscribe",
"ClientCode": "<client_code>",
"MarketFeedData": [
{"Exch": "N", "ExchType": "D", "ScripCode": 48508}
]
}{
"Exch": "N",
"ExchType": "D",
"Token": 48508,
"OpenInterest": 2388700,
"DayHiOI": 2400000,
"DayLoOI": 2345100
}- Purpose: Lifecycle status of orders (place/modify/cancel/trade/SL)
{
"Method": "OrderTradeConfirmations",
"Operation": "Subscribe",
"ClientCode": "<client_code>"
}{
"Method": "OrderTradeConfirmations",
"Operation": "Unsubscribe",
"ClientCode": "<client_code>"
}{
"ReqType": "P",
"Status": "Placed",
"ScripCode": 1660,
"Price": 425,
"Qty": 1,
"BuySell": "B",
"ReqStatus": 0
}{
"ReqType": "T",
"Status": "Fully Executed",
"TradedQty": 1,
"Price": 434.2,
"ExchTradeTime": "2024-05-09 11:32:34"
}- Validate correct fields only (minimal subset)
- Compare consistency with
MarketFeedV3 - Validate against large inputs (up to 3000 scrips)
- Test concurrent subscriptions for stability
| Code | Description |
|---|---|
| N | NSE |
| B | BSE |
| M | MCX |
| Code | Description |
|---|---|
| C | Cash |
| D | Derivatives (F&O) |
| U | Currency Derivatives |
| Value | Description |
|---|---|
| Subscribe | Start receiving live data |
| Unsubscribe | Stop receiving live data |
- Subscribe only to required scrips to manage bandwidth and rate limits.
- Use heartbeat (
PING/PONG) to maintain connection health. - Monitor server responses for real-time margin alerts or trade confirmations.
- Avoid exceeding 3000 subscriptions per session.