HI, I am using the following API to get quotes one by one. "https://api.kite.trade/instruments/NSE/INFY?api_key=xxx&access_token=yyy" . I am calling this 10 times for 10 scripts. After 5 to 6 times, it is throwing " {"status": "error", "message": "Too many requests", "error_type": "NetworkException"}"
Is there a way to get 10 scripts data at once? (I need this several times in a day) There is instruments API which says.. that it has more data and should be called once in a day.
Thank you Sujith. Is there a possibility to increase this cap? 3 per second is very less. Also which API should I use to get live 5minutes candle data?
Hi @chamu, I am afraid it is not possible to increase API rate limiting.
Our 5minutes candles available on Historical data API are constructed using five 1minute candles.
During live market hours system listens to every tick from the exchange and constructs 1minute candle by end of the minute which happens for all the scrips that are being traded on the exchange for the day. End of the minute all these candles are written into the database and every new request to write is added to the queue. There can be a five seconds delay since it is database write operation, we can't guarantee a particular second at which it can be written. Let us say you are accessing 3:05 PM 5minute candle at 3.05.02 PM, it might give you a candle that is constructed using four 1minute or five 1minute candles.
If your algorithm can't afford a couple of seconds of delay then I would suggest constructing your own candles.
Hi, I am sending 2 requests every 3 seconds to get live quotes data but still i am facing this error "{"status": "error", "message": "Too many requests", "error_type": "NetworkException"}"
@rakeshr Thanks, Yes I have already implemented code according to this flow. but there is one more problem that this is not working in 1 minute cronJob. so can you suggest me how can handle this code in 1 minute cron.
var KiteTicker = require("kiteconnect").KiteTicker; var ticker = new KiteTicker({ api_key: "api_key", access_token: "access_token" });
// set autoreconnect with 10 maximum reconnections and 5 second interval ticker.autoReconnect(true, 10, 5) ticker.connect(); ticker.on("ticks", onTicks); ticker.on("connect", subscribe);
onTicks is called in the loop once you start a webscocket connection and subscribe to tokens. As and when tick data is received, onTicks is called. You just need to offload or dump the data in the secondary thread to your DB or storage.
All Kite Connect API calls are restricted to 3 requests per second. If you make more API calls than this you will see this error.
If you are trying to fetch live market data then use websockets.
I am afraid it is not possible to increase API rate limiting.
Our 5minutes candles available on Historical data API are constructed using five 1minute candles.
During live market hours system listens to every tick from the exchange and constructs 1minute candle by end of the minute which happens for all the scrips that are being traded on the exchange for the day.
End of the minute all these candles are written into the database and every new request to write is added to the queue. There can be a five seconds delay since it is database write operation, we can't guarantee a particular second at which it can be written.
Let us say you are accessing 3:05 PM 5minute candle at 3.05.02 PM, it might give you a candle that is constructed using four 1minute or five 1minute candles.
If your algorithm can't afford a couple of seconds of delay then I would suggest constructing your own candles.
I am sending 2 requests every 3 seconds to get live quotes data but still i am facing this error
"{"status": "error", "message": "Too many requests", "error_type": "NetworkException"}"
It is across all the API calls not confined to one endpoint.
At any point of time, you can make 3 requests per second.
Can you tell me how to use WebSocket streaming in nodejs code.
You can go through this example.
Yes I have already implemented code according to this flow. but there is one more problem that this is not working in 1 minute cronJob. so can you suggest me how can handle this code in 1 minute cron.
I'm using this npm (https://www.npmjs.com/package/kiteconnect). So can you describe how to use this npm code in 1 minute cronJobs.
var ticker = new KiteTicker({
api_key: "api_key",
access_token: "access_token"
});
// set autoreconnect with 10 maximum reconnections and 5 second interval
ticker.autoReconnect(true, 10, 5)
ticker.connect();
ticker.on("ticks", onTicks);
ticker.on("connect", subscribe);
ticker.on("noreconnect", function() {
console.log("noreconnect");
});
ticker.on("reconnecting", function(reconnect_interval, reconnections) {
console.log("Reconnecting: attempt - ", reconnections, " innterval - ", reconnect_interval);
});
function onTicks(ticks) {
console.log("Ticks", ticks);
}
function subscribe() {
var items = [738561];
ticker.subscribe(items);
ticker.setMode(ticker.modeFull, items);
}
// CronJob Code for 1 minute
var cronJob = new CronJob("*/1 * * * *", async function () {
console.log("\n\n\nCRON running at----------------", new Date());
//ticker.autoReconnect(true, 10, 5)
// ticker.connect();
// ticker.on("ticks", onTicks);
// ticker.on("connect", subscribe);
},{
scheduled: true,
timezone: "Asia/Calcutta"
});
cronJob.start();
@Please help me for resolved this issue.
Thanks in advanced.
As and when tick data is received, onTicks is called.
You just need to offload or dump the data in the secondary thread to your DB or storage.