We've noticed a growing abuse of the APIs (by our own paying Kite Connect users) over the last few weeks. This pertains primarily to pulling market quotes (/instruments) and historical data. Some users have incessantly sent up to 30,000 requests in 10 minutes polling the same market quote API, with no regard for fair use best practices. As a result, we've imposed strict rate limiting procedures.
/instruments (market quote call) - max 60 requests per minute /instruments/historical - max 120 requests per minute (2 requests/sec)
If you exceed the limit, you'll get a 429 (Too many requests) error temporarily until the threshold is cleared. Your account, for now, is not affected.
The correct way to retrieve a live quote is to use the WebSocket API (there are Python and Java clients available) which offers live streaming ticks, and not poll the /instruments API which is only meant for passive, one-off calls.
@pankajiit_cse If you are consistently getting this error, that means you are sending more than 60 requests per minute. The historical API is not meant to be polled every second. How many requests are you sending?
PS: For live data, you should use the WebSocket API.
@Kailash@vivek 1. Is the rate limit is Per API basis or per instrument Basis for historical data. 2. My Algoritham requires to read all data points for each instrument. Hence I am trying to call API every .5 sec interval. For different instruments. Am I doing it correct? 3. What would be the ideal way to download last 2 years of data for all instruments ?
1) @muke5hy It's per API. 2) For live data points (you can compute candles from ticks), you should use the WebSocket API. 3) We have close to a billion rows in the historical data store, so there's no easy way as of now. We're contemplating how to make to make the availability better.
@Kailash@vivek My 2 cents.. This is a good step. However, please improve your web-sockets documentation and please make it include links to the python ws client and/or some sample code. From my experience, it is quite geeky for an average developer to fetch and decrypt that binary dataframe correctly.
@vivek You have a bug which might be making this worse. It seems anyone can call https://api.kite.trade/instruments with just the api_key, without having the api_secret. api_key is public so they can be obtained easily.
I tested it just now and it works. It's possible that API abusers are using others' api_key. With rate-limiting in place, now genuine users will get penalized for no fault of theirs (for eg, some genuine user who was calling this API only 100 times a minute, but his API key was being abused by others 10000 times a minute).
Fix would be to make api_secret mandatory for the instruments API.
Although I agree on imposing limits, I think if u can address deficiency in your API, u can very much reduce number of requests per second hitting your server. I had mentioned it earlier but would like mention it again.
Let user specify list of symbols and minute range Index(like 18 to 23) where index 1 corresponds to 9:16am, 2 corresponds to 9:17am etc IN ONE API REQUEST and u can return all 1-minute candles for those 5 minutes for each symbol in list
Hi, I am working with 1 Min Candles, So I need to pull 1500 Stocks every min (In First 5 Sec) for Recent 1 Min Candle, How i can do this with out abusing API Rate Limits. I don't Need historical data. I Just need last 1 Min. Hope I am clear,
Hi @lazydragonfist, As of now, we don't have time-based historical data fetch feature, we will provide it in future. For now, the feasible solution will be to make your own candles using websocket ticks.
Hi @lazydragonfist, A Kite Connect app can open three websocket connections simultaneously. You can subscribe up to 600 scrips. Can you let me know about your use case?
That mean I can get 600 (3 Websocket Connections) Stock Prices live and i should build 1 Min Candles with Them, Can I open More than 3 Websocket connections with my Own .Net project ?
Hi @lazydragonfist, There is a soft limit for 3 connections for an api_key, soon we will be setting a hard limit for this.
You can listen to 600 scrips and store data with 3 connections. Please note that if you subscribe for a 201st token then there won't be error message as of now, it will just not give you data. We will provide error message from next version of websockets.
Make sure not to block the thread which listens to ticks otherwise you may miss data in between. I am not sure if this will fit your purpose but I would suggest using something like, the main thread for listening to ticks and spawn a worker thread which will process all your calculations and do IO operations.
Hi @ravikumar555, Fetching quote for multiple scrips in one API call is not available yet. We will include it in next version of Kite Connect. You can fetch quote for single scrip in one API call. You can check out documentation here.
if i am pulling 15 min historical candles for 100 instruments , then also i will get too many request which is not fair . this rate limit should be cummulative
@sujith rate limit for historical api at 2 requests/second is very restrictive. Please remember we pay specifically Rs. 2000 per month for this single API. The API itself does not allow multiple tokens at once. My use case requires me to send 200 API requests at a particular time during trading hours. Only once in a day. That is not overshooting fair use. What is the alternative I can use?
@kavanlimbasiya, The historical data API is provided for backtesting purposes only. For live market strategies, we suggest you to generate candles at your end using the live market data provided via Websocket API. You can get started here.
PS: For live data, you should use the WebSocket API.
1. Is the rate limit is Per API basis or per instrument Basis for historical data.
2. My Algoritham requires to read all data points for each instrument. Hence I am trying to call API every .5 sec interval. For different instruments. Am I doing it correct?
3. What would be the ideal way to download last 2 years of data for all instruments ?
2) For live data points (you can compute candles from ticks), you should use the WebSocket API.
3) We have close to a billion rows in the historical data store, so there's no easy way as of now. We're contemplating how to make to make the availability better.
This is a good step. However, please improve your web-sockets documentation and please make it include links to the python ws client and/or some sample code.
From my experience, it is quite geeky for an average developer to fetch and decrypt that binary dataframe correctly.
I tested it just now and it works. It's possible that API abusers are using others' api_key. With rate-limiting in place, now genuine users will get penalized for no fault of theirs (for eg, some genuine user who was calling this API only 100 times a minute, but his API key was being abused by others 10000 times a minute).
Fix would be to make api_secret mandatory for the instruments API.
PS: Do you have a bug-bounty program?
We don't have bounty program yet but we welcome feedbacks and bug reports
Also /instruments is in a different limit zone. It should not affect standard API calls.
Finally, yes, we'll make access_token mandatory.
I had mentioned it earlier but would like mention it again.
Let user specify list of symbols and minute range Index(like 18 to 23) where index 1 corresponds to 9:16am, 2 corresponds to 9:17am etc IN ONE API REQUEST
and u can return all 1-minute candles for those 5 minutes for each symbol in list
I am working with 1 Min Candles, So I need to pull 1500 Stocks every min (In First 5 Sec) for Recent 1 Min Candle, How i can do this with out abusing API Rate Limits. I don't Need historical data. I Just need last 1 Min. Hope I am clear,
As of now, we don't have time-based historical data fetch feature, we will provide it in future. For now, the feasible solution will be to make your own candles using websocket ticks.
I was concern about Rate Limit, Can I open 1500 Sockets or get Historical data Requests 1500/Min .
A Kite Connect app can open three websocket connections simultaneously. You can subscribe up to 600 scrips.
Can you let me know about your use case?
Its not clear about what you said "Kite Connect App". I was expecting API to use in my Custom Build PHP Application for NSE Stock Scanner.
Users can subscribe for upto 200 scrips with one Websocket connection.
You can check out https://screener.smallcase.com/welcome
Can I open More than 3 Websocket connections with my Own .Net project ?
There is a soft limit for 3 connections for an api_key, soon we will be setting a hard limit for this.
You can listen to 600 scrips and store data with 3 connections. Please note that if you subscribe for a 201st token then there won't be error message as of now, it will just not give you data. We will provide error message from next version of websockets.
Make sure not to block the thread which listens to ticks otherwise you may miss data in between.
I am not sure if this will fit your purpose but I would suggest using something like, the main thread for listening to ticks and spawn a worker thread which will process all your calculations and do IO operations.
Can we get quotes for a list of Scrips in a single API? Pls share details if so
Fetching quote for multiple scrips in one API call is not available yet. We will include it in next version of Kite Connect.
You can fetch quote for single scrip in one API call. You can check out documentation here.
The historical data API is provided for backtesting purposes only. For live market strategies, we suggest you to generate candles at your end using the live market data provided via Websocket API.
You can get started here.