[API v2] WebSocket Spot/Index Data Missing for NIFTY, SENSEX & MCX (Code 8/Ticker)

Hi,

I am migrating my custom application to the Dhan API v2 WebSocket (wss://api-feed.dhan.co?version=2).

I have successfully established a connection and am receiving live data for Options contracts across NSE, BSE, and MCX using the Binary Subscription (Request Code 21).

However, I am unable to receive the Spot Price / Underlying Index Value for any exchange. The server acknowledges the subscription but sends no data for these specific Instrument IDs.

The Issue: I am sending a Binary Subscription (Code 21) for the following, but receiving silence:

  1. NSE Indices: NIFTY 50 (ID 13) / BANKNIFTY (ID 25).

    • Tried Exchange Segment: 1 (NSE_EQ) and 0 (IDX).
  2. BSE Indices: SENSEX.

    • Tried Exchange Segment: 0 (IDX), 4 (BSE_EQ) and 8 (BSE_FNO).
  3. MCX Spot: Crude Oil / Natural Gas Underlying.

    • Tried Exchange Segment: 5 (MCX_COMM).

My Questions:

  1. Correct Segments: What are the correct ExchangeSegment values to use in the Subscription Packet (Code 21) for Indices (NSE/BSE) and Commodity Spot (MCX)?

  2. Packet Type: Does Index data require a different Request Code (e.g., 15 Ticker instead of 21 Full)?

  3. Response Structure: Is the Response Code for Indices different from the standard 8 (Full Quote)? If so, could you share the byte map for the Index packet?

Technical Context:

  • Auth: V2 URL Auth (Working).

  • Options Data: Working perfectly (receiving LTP at Offset 8).

  • Spot Data: No incoming packets.

Any documentation on the specific Segment/Instrument type mapping for Indices in v2 would be a lifesaver.

Thanks!

Hi @desTiny ,

Just a quick clarification to help you here.

Request Code 21 is meant for the full packet, which includes market depth and open interest. Since these are not available for spot indices, index data will not be pushed using this request code. For indices like NIFTY and SENSEX, please use the IDX_I exchange segment to fetch spot prices.

For commodities, the correct exchange segment is MCX_COMM . As spot charts are not available for commodities such as Crude Oil and Natural Gas, you may use near-expiry contract security IDs to fetch the required data.

Hope this clears things up. Please let us know if you need any further help.

1 Like