Now Live: Live Market Feed on DhanHQ Trading APIs

Hello Traders,

We have talked about our tech stack and approach about building Dhan in this community a lot of times. And as we scale Dhan, we continue to build awesome products and features which aim to make your trading and investing experience seamless.

We made trading APIs for our stack available to every Dhan user very early in our journey (within four months of launching) under DhanHQ and we have kept on improving the technology stack with every user feedback and suggestions each day. Our vision for building this API stack is to empower users to trade from their own systems, incorporating their unique customisations and thought processes and we serve as a reliable execution engine, facilitating a seamless trading experience for its users.

Our core transaction execution engine across all exchanges powers all Dhan products - not only our flagship products like Dhan and Options Trader but also our strategic partnerships with industry leaders such as TradingView and smallcase. On top of our execution engine are our APIs which process orders and transactions under seconds, handling millions of requests each day. With DhanHQ APIs, we have aimed to deliver everything that a tech geek or algotrader needs - speed, reliability, low latency and of course minimal or no additional costs.

However, one of the missing pieces, which has also been the most requested feature from Dhan, is Real-time Data as part of our API offering. Yes, this has been requested for a very long time, but building the infrastructure for all our products and extending it to Open API came with its own set of challenges. Our primary goal was to develop a reliable and faster solution that could scale effectively.

We are delighted to announce that we are now live with Live Market Feed as part of our DhanHQ Data API Stack.

Live Market Feed is available as part of Data APIs on the DhanHQ Superfast Trading & Investing API stack, which any user can subscribe to at a fees of just Rs. 499 per month + taxes. We have added a nominal subscription cost to the Market Feed APIs to cover the infrastructure cost of providing low-latency, reliable data with no limitations to API traders. This step is taken to prevent misuse while ensuring accessibility for legitimate users.

Live Market Feed will give you Real-time market data across all exchanges and segments over Websocket. Websocket is a bidirectional communication protocol over a single established TCP connection which you can learn more about here.

With DhanHQ Live Market Feed, you get following exchanges and segments:

  • NSE - Equity, Futures, Options, Currency
  • BSE - Equity, Futures, Options, Currency
  • MCX - Commodity

To empower traders and tech geeks building systems on top of our API stack, we have enabled Live Market Feed users to,

  • Subscribe upto 5000 instruments on a single websocket connection at this moment
  • We have built systems robust to send multiple formats of data on a single connection on any number of scrips.
  • Not just this, you can establish up to 5 connections of Market Feed as a Data API user.

On DhanHQ Live Market Feed, you can subscribe to different Market Data types as per your requirement:

  • LTP and Trade Data
  • Market Depth
  • Volume
  • OI
  • Previous Close and others.

This data will be available in the following packet types via DhanHQ Libraries:

  • Ticker Packet: LTP data
  • Quote Packet: LTP + Best bid-ask + OHLC data
  • Market Depth Packet: Bid-Ask up to level 5

So, here’s how you can get started with DhanHQ Live Market Feed:

To access the Live Market Feed:

  • Log in to web.dhan.co.
  • Navigate to DhanHQ Trading APIs.
  • Go to Data APIs and subscribe to Live Market Feed.

Once you have subscribed to Data APIs, your subscription will be auto-renewed every 30 days from your ledger, so that you do not need to worry about renewing subscription ever.

We are really excited to extend Market Feed to you on APIs, and we look forward to your feedback on the same. Also, if you want to contribute to any of our libraries on GitHub, feel free to do as we aim to make and maintain API libraries completely Open Source.

– Hardik
Product

7 Likes

Thanks @Hardik and Dhan team. This opens up new possibilities for us traders.

@Hardik
It’s a great news,
So it’s 499 + tax for everyone or it’s free for super trader ??

2 Likes

@Hardik
Can you ask Quantower to integrate this ?

@Hardik I’m incredibly impressed with the DhanAPI Market feed and can’t wait to put it to the test through some integration tests. Kudos to the @Dhan Team for your unwavering commitment to improving the experience for traders – it’s truly outstanding!:slight_smile:
madefortrade

2 Likes

Hi @HIR

We have simplified this now - we have two types of APIs (Trading & Data APIs). Trading APIs are free for all and Data APIs are INR 499 per month.

As usual, we charge competitively to cover for our infrastructure investments & avoid misuse. We understand many users have already their integrations for marketfeed and historical data, so they have a choice to integrate just the trading APIs for free (no cost). While those who are getting started with building their own web-sockets for data it is INR 499, possibly also for those who want to switch to our market-feed.

Hope this helps.

Thank you for your positive feedback! We highly value the input and suggestions from our community members. Your continuous contributions are greatly appreciated, so please keep sharing your thoughts with us!

Looking forward to building a robust algo trading community :rocket:

2 Likes

I am very much impressed with the work done by Dhan team. I am a trader and a developer at the same time. I was exploring DhanHq, I am facing issues with the Live Market Feed Websocket. Can you please provide some sample around binary authentication . It says " you can send request binary packet to the below endpoint using WebSocket library." How can we do that. Can you please add some sample around curl and rest or testing it via Postman.

Also, if someone is good in other Tech-Stack like Java or Go or Node. Can you add support and sample Api and SDK for those or Dhan only plan to extend support only with the Python Programming Language or Python SDK.

Kindly add support for other languages like Java and add sample testing for Web socket via Postman and sample of Auth Binary Message. It’s hard to get crux of it.

2 Likes

Don’t we get data api for free after executing 25 trades per month?

Can someone help with Java based web socket implementation of this.

Hello @rahulbajaj

Currently, the official API client library is only available in Python. We do have API library in .js which is community contributed. Would be great if someone from the community can help you here.
Will try to add Postman sample for websockets.

@chandangowdatk

Welcome to Dhan Community! Post 10 February 2024, there is a subscription cost of ₹499 + taxes per month for Data APIs. In case you were already using Data APIs, you will automatically be eligible to use it for the month of February, for smooth transition.

import DhanSDK
ModuleNotFoundError: No module named 'DhanSDK' 

Is this changed ?

Thanks Hardik. It will really helpful if I can see the Postman Samples for the Web Socket to access the Live Market Feed. Once I go through the Postman sample, It will helpful for me build something around Java/Spring WebSocket Framework. I can see Live Market Feed or wherever we are having Web Socket, there is no sample provided. For Static Calls like https call the document is really good but wanted to have samples around Web Socket also. Thanks in advance. Will be looking to hear from you really soon.

Hello @rahulbajaj

Yes, although the messages are sent in binary, will try to add example binary code so that you can construct the same structure via Java as well. We have written description of the same in the documentation itself, but will try to add reference binary packets as well.

@mahadevan yes. You can refer to ‘Websocket Usage’ code on GitHub to get started, with minor updates on library: GitHub - dhan-oss/DhanHQ-py: The official Python client for communicating with the Dhan API.

1 Like

Thanks Hardik, That will be of great help. Yes I have gone through the documents thoroughly. That too couple of time. I have worked with websockets before but auth and param used to be plain text ‘utf-8’ format. I have never worked on websockets where I need to pass on binary packet to get the data out. I know you folks have done that to reduce the size of the message and which in eventually lower latency or delay. Also, I was stretching my head to find some references around google like to convert a message to binary of fixed length but most of sample examples are using chat application for demo which is different from our usecases.

@Hardik Don’t we get it for free after executing 35 F&O trades

Please clarify two things.

  1. If there is a limit on the number of stocks that we can subscribe to, in some places it says no limit, while in documentation in some places it says maximum of 100 symbols.

  2. Does the streaming have percentage change data for stock available? This is not a deal breaker while first one is really important.

These are my requirements, so wanted to confirm before I pay and start developing.

Thanks.