logo

Fetching Market Depth (Level 2) Through the HDFC SKY API

By HDFC SKY | Published at: Oct 29, 2026 02:17 PM IST

Fetching Market Depth (Level 2) Through the HDFC SKY API

Open Free Demat Account

Open Free Demat Account

By signing up I certify terms, conditions & privacy policy

Market prices tell only part of the story. To understand how buyers and sellers are positioned in the market, traders often rely on market depth data. The HDFC SKY WebSocket API allows applications to receive real-time market data, including up to five levels of bid and offer market depth for supported instruments, through a continuous streaming connection.

This guide explains what market depth is, why it is useful, and how to set up your application to receive Level 2 market data using the HDFC SKY API.

What Is Market Depth?

Market depth, also known as Level 2 market data, shows the pending buy and sell orders available for a security at different price levels. Instead of displaying only the latest traded price, it provides a broader view of current market activity.

This information helps users understand how much buying and selling interest exists at different prices and how market demand and supply are changing.

Why Is Market Depth Important?

Market depth provides additional information that is not available through the last traded price alone.

Here are some of its key benefits for traders:

  • View multiple bid and offer price levels.
  • Understand the available buying and selling interest.
  • Monitor changes in market liquidity.
  • Analyse order flow more effectively.
  • Support real-time trading and monitoring applications.

For applications that display live market activity, Level 2 data offers a more complete market view than price updates alone.

Why Use the HDFC SKY WebSocket API?

The HDFC SKY WebSocket API is the recommended method for receiving live market data, including market depth.

Unlike request-response communication used by REST APIs, a WebSocket maintains a continuous connection with the HDFC SKY platform. As market conditions change, new data is streamed automatically to your application without repeatedly sending requests.

This approach improves efficiency and allows applications to receive live updates with minimal delay.

Also Read: HDFC SKY API Authentication and Login Flow Explained

Connect to the HDFC SKY WebSocket

Complete the authentication process so that your application can establish a WebSocket connection. The WebSocket creates a continuous communication channel between your application and the HDFC SKY platform. This allows live market updates to be delivered automatically as soon as they become available.

After the connection is established and the session is authenticated using a valid Access Token, your application becomes ready to subscribe to market data.

Subscribe to Market Depth Data

After establishing the WebSocket connection, the next step is to subscribe to the instruments for which you want to receive live market depth. Your application sends a subscription request that specifies the required instrument along with the appropriate exchange and market segment.

A typical subscription identifies:

  • The exchange or market segment.
  • The Scrip ID of the instrument.
  • The type of market data required.

Once the subscription is successful, the WebSocket starts streaming real-time market data for the selected instrument. Depending on the subscription type, this can include market depth, Last Traded Price (LTP), OHLC values, and other supported data fields.

Understanding Level 2 Market Data

After subscribing successfully, your application starts receiving Level 2 market information. The market depth stream can include the following details.

  1. Bid Prices
    Bid prices represent the prices at which buyers are willing to purchase a security. Multiple bid levels help users understand buying interest at different price points.
  2. Offer Prices
    Offer prices, also known as ask prices, represent the prices at which sellers are willing to sell a security. Viewing multiple offer levels helps users understand the available selling interest.
  3. Bid and Offer Quantities
    Each bid and offer level also includes the corresponding quantity available at that price. This information provides additional insight into market liquidity.
  4. Five Levels of Market Depth
    The HDFC SKY WebSocket API supports up to five levels of bid and offer market depth for supported instruments. Displaying multiple price levels provides a more detailed view of the order book than relying only on the latest traded price.

How Can Market Depth Be Used?

Market depth data supports a variety of trading and market monitoring applications.

Some common use cases include:

  • Display live order book information.
  • Monitor buying and selling activity.
  • Analyse market liquidity.
  • Build advanced trading dashboards.
  • Create portfolio monitoring applications.
  • Support market research and analytics.

These applications benefit from continuous market updates without repeatedly sending API requests.

Good Practices for Fetching Market Depth

Following a few simple practices can help you build a reliable market data application.

Consider the following recommendations:

  • Complete authentication before opening the WebSocket connection.
  • Use a valid Access Token for every authenticated session.
  • Register the required Static IP address for your application.
  • Subscribe only to the instruments your application needs.
  • Remove subscriptions that are no longer required.
  • Stay within the supported WebSocket connection and subscription limits.
  • Monitor heartbeat messages to verify that the connection remains active.

Following these practices helps improve performance while maintaining a stable WebSocket connection.

Common Mistakes to Avoid

Developers new to live market data streaming often encounter a few common issues.

Avoid the following mistakes:

  • Attempting to connect before completing authentication.
  • Using an expired Access Token.
  • Registering an incorrect Redirect URL.
  • Forgetting to configure the required Static IP address.
  • Exceeding the supported subscription limits.
  • Opening unnecessary WebSocket connections.
  • Expecting continuous market depth updates through REST APIs instead of the WebSocket service.

Avoiding these issues can help reduce connection failures and improve the overall reliability of your application.

Conclusion

The HDFC SKY WebSocket API provides an efficient way to receive real-time Level 2 market depth for supported instruments. After authentication and subscription, applications can stream bid and offer data, along with other supported market information, through a persistent WebSocket connection. By following the documented setup process and connection guidelines, developers can build responsive applications that deliver reliable live market data.

Summarize with AI
Google GeminiChatGPTPerplexity AIAnthropic AIGrok AI
Desktop BannerMobile Banner

Invest Anytime, Anywhere

Get it on Google PlayGet it on App Store

Open Free Demat Account Online

By signing up I certify terms, conditions & privacy policy