I have recently purchased the paid subscription for KITE Connect and I am using the PHP Client for KITE Connect.
I tried calling the web-sockets and I am able to make a successful connection but there are not bytes being returned, the size of the packet being returned is zero, I am trying with Tokens(19016706 , 408065), mode is LTP. Can anyone please provide some inputs on this.
Hi @Pandiyaraj, You keep getting heartbeat tick which will be zero bytes. You can ignore that. For this token 19016706, you won't get ticks as it is not being traded as of now. For 408065, you can expect a maximum of one tick per second.
Hi Sujith I tried both tokens still i am getting zero bytes only. I am trying with active public_token only. Is there any way to do get a live data market .
After subscription, i tried to get full packet structure using below structure, Getting full packets code : [webSocket send:{"a":"mode","v":["full",["138179588"]]}];
I changed instrument token lot of times, every time i am getting only 1 byte of data in the response.
Hi @Pandiyaraj, Getting 1byte is not a bug. It is heartbeat tick. You will keep getting 1-byte ticks even if you don't subscribe for any token. It is the basic behavior of websockets.
The reason you are not getting ticks is that you are sending tokens as a string while subscribing. You need to send it as a number. In simple words remove quotes around the tokens.
Thanks for your help. I changed the number instead of the string, even though getting 1 byte only. I want live market data of that particular instrument token. But getting only 1 byte.
Let me know, When the full data will be return ? i am struggling with this on last 3 days.
Hi @Pandiyaraj, The scrip you are trying is not being traded. Hence there are no ticks. I would suggest trying some liquid scrip. You can check crude oil or Gold for now.
I tried with '53401863' . It returns 48 bytes but in API Documentation , Full Mode contains 164 bytes How can we identify this ? i am receiving 48 bytes I try to decode the bytes ?
I am getting 48 bytes of data for this instrument token "53401863". While i use another instrument token like "3813889" , "1374209" getting only 1 bytes of data.
I want a app like KiteMarketWatch, Please give me what types of instrument tokens i need to use for getting live market price.
I subscribed both these instrument tokens . Actually i am not understand , how to identify which scrips are traded and not traded in that instrument list Api.
Please suggest me how to identify which scrips are traded and not?
Also can you please tell what series types of data will return in our socket.
I want a live market price data of given instrument token, but i can't get full bytes every time.
Hi @Pandiyaraj, All the scrips are ideally being traded on EQ series, when there is excessive speculation or for some reason exchange may decide to curb liquidity and move the scrip to BE or BL series. Intraday trades are not allowed on these scrips. As a broker, we don't get notified when the scrip is moved to T2T segments(BE, BL).
The only source as of now to know which scrip is being traded on which segment is by CSV file provided by exchange here.
To know more about T2T segments check out this thread.
Thanks , How to get all nifty futures instrument tokens? I don't have knowledge about this. So Please give me some ideas to get all nifty futures list and their instrument tokens.
Hi @Pandiyaraj, Kite Connect API supports only fetching of either all instruments that are being traded today or fetching instruments for an exchange. You can check out example here.
Why i am getting always 1 byte only. I want full data Can you please suggest me some which instrument tokens are provide full 168 bytes. I am really frustrated, we can't able to plot graph values based on that LTP and Change Price Tick. Please give a solution for this.
If i am getting 1 Byte means, How do i know wheather the prices is changed or not?
I want to display live data feed of that symbol in graph, So suggest me some idea and instrument tokens.
HI @Pandiyaraj, The same websocket is used on all our platforms and all other Kite Connect users. I would suggest checking your code.
As I have mentioned above, 1 byte is a heartbeat tick which is like confirmation that you are connected to the server. It has nothing to do with your subscription for tokens.
Hi @Pandiyaraj, Did you try during market hours or after market? You will keep getting 1byte every second once you connect to websocket, you will get data if there is a change in tick data. In other words, you will get data only if the instrument is being traded.
I Checked with both market hours and after market hours too.. I don't know how to identify instrument is Traded or Not?? I don't have knowledge about this .
I am using Objective C Client Code based on JAVA Kite Connect. Because i am using in iOS Mobile app development. Based on JAVAKiteConnect , I Write the code for it. I able to get the LTP and OHLC and Instrument token everything.. My problem was sometimes i am getting 168 Bytes and some times only 1 byte heart byte.
From friday onwards i am getting a 1 Byte data only for this instrument token "12732162" Whereas i am getting the data value in Historical API... What is the issue in that?
You keep getting heartbeat tick which will be zero bytes. You can ignore that.
For this token 19016706, you won't get ticks as it is not being traded as of now.
For 408065, you can expect a maximum of one tick per second.
I tried both tokens still i am getting zero bytes only. I am trying with active public_token only. Is there any way to do get a live data market .
Can you make a gist and paste the link here?
After connecting the websocket , I subscribe the instrument token using below structure in my code,
Subscribe code :
[webSocket send:{"a": "subscribe","v": [138179588]}]
After subscription, i tried to get full packet structure using below structure,
Getting full packets code :
[webSocket send:{"a":"mode","v":["full",["138179588"]]}];
I changed instrument token lot of times, every time i am getting only 1 byte of data in the response.
Can you please help me to get the full data.
Thanks in advance
Can you paste your complete code here?
Please check the full code,
For subscription :
- (void)subscribleInfy{
NSMutableDictionary *dict = [@{@a:@subscribe,@v:@[@24771586]} mutableCopy];
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict
options:0
error:nil];
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
[webSocket send:jsonString];
[self getFullQuotes];
}
For getting full quotes :
- (void)getFullQuotes{
NSMutableDictionary *dict1 = [@{@a:@mode,@v:@[@full, @[@24771586]]} mutableCopy];
NSData *jsonData1 = [NSJSONSerialization dataWithJSONObject:dict1
options:0
error:nil];
NSString *jsonString1 = [[NSString alloc] initWithData:jsonData1 encoding:NSUTF8StringEncoding];
[webSocket send:jsonString1];
}
Please let me know, why the data returns only 1 byte.
Getting 1byte is not a bug. It is heartbeat tick. You will keep getting 1-byte ticks even if you don't subscribe for any token. It is the basic behavior of websockets.
The reason you are not getting ticks is that you are sending tokens as a string while subscribing. You need to send it as a number.
In simple words remove quotes around the tokens.
Thanks for your help. I changed the number instead of the string, even though getting 1 byte only. I want live market data of that particular instrument token. But getting only 1 byte.
Let me know, When the full data will be return ? i am struggling with this on last 3 days.
Can you log and check if you are sending message as json like this and not an array.
Json is same what you mention above, Please check below json (It's for single instrument)
{"a":"subscribe","v":[17121538]}
Thanks
The scrip you are trying is not being traded. Hence there are no ticks. I would suggest trying some liquid scrip. You can check crude oil or Gold for now.
I tried with a instrument token '136676100' & '4915969'
Details of instrument token :
1. 136676100,533891,RELGOLD,R* SHARES GOLD EXCHANGE TRADED,0.0,,0.0,0.01,1,EQ,BSE,BSE
2. 4915969,19203,SGBNOV24-GB,2.50% GOLDBONDS2024 TR-VI,0.0,,0.0,0.01,1,EQ,NSE,NSE
JSON String :
1. Subscription = {"a":"subscribe","v":[4915969,136676100]}
2. Access full mode = {"a":"mode","v":["full",[4915969,136676100]]}
But , i am getting only 1 byte again, can you please give live data market sample instrument token.
You can try for this 53401863
I tried with '53401863' . It returns 48 bytes but in API Documentation , Full Mode contains 164 bytes
How can we identify this ? i am receiving 48 bytes I try to decode the bytes ?
Response : I tried to convert a string , but it returns null value.
String Conversion : (Message is response)
[[NSString alloc] initWithData:message encoding:NSUTF8StringEncoding]
Is anything i am doing wrong in this ?
You get live ticks in binary. You need to parse data. You can check out java client or python client.
I am getting 48 bytes of data for this instrument token "53401863". While i use another instrument token like "3813889" , "1374209" getting only 1 bytes of data.
I want a app like KiteMarketWatch, Please give me what types of instrument tokens i need to use for getting live market price.
I am getting instrument token from this API Call : https://api.kite.trade/instruments?api_key=#MYAPIKEY
3813889 is CENTRALBK-BE and 1374209 is CHENNPETRO-BE.
Both these scrips are not traded. Hence you didn't get any ticks.
These above scrips are traded in EQ series. You need to subscribe for that instrument tokens.
1byte is heartbeat tick which you will get even when you don't subscribe to anything.
I subscribed both these instrument tokens . Actually i am not understand , how to identify which scrips are traded and not traded in that instrument list Api.
Please suggest me how to identify which scrips are traded and not?
Also can you please tell what series types of data will return in our socket.
I want a live market price data of given instrument token, but i can't get full bytes every time.
Thanks in advance
All the scrips are ideally being traded on EQ series, when there is excessive speculation or for some reason exchange may decide to curb liquidity and move the scrip to BE or BL series.
Intraday trades are not allowed on these scrips.
As a broker, we don't get notified when the scrip is moved to T2T segments(BE, BL).
The only source as of now to know which scrip is being traded on which segment is by CSV file provided by exchange here.
To know more about T2T segments check out this thread.
Thanks , How to get all nifty futures instrument tokens? I don't have knowledge about this. So Please give me some ideas to get all nifty futures list and their instrument tokens.
Kite Connect API supports only fetching of either all instruments that are being traded today or fetching instruments for an exchange.
You can check out example here.
Why i am getting always 1 byte only. I want full data Can you please suggest me some which instrument tokens are provide full 168 bytes. I am really frustrated, we can't able to plot graph values based on that LTP and Change Price Tick. Please give a solution for this.
If i am getting 1 Byte means, How do i know wheather the prices is changed or not?
I want to display live data feed of that symbol in graph, So suggest me some idea and instrument tokens.
Thanks
Pandiyaraj
The same websocket is used on all our platforms and all other Kite Connect users. I would suggest checking your code.
As I have mentioned above, 1 byte is a heartbeat tick which is like confirmation that you are connected to the server. It has nothing to do with your subscription for tokens.
Thanks for your response.. Please see the below steps where i used in my code If anything wrong means please correct me.
Step 1:
I fetch the instrument token lists using this API Call.
Url : https://api.kite.trade/instruments/NSE/?api_key =(api_key)
Step 2 :
Connecting the websocket with the user id, public token and apikey
Url : wss://websocket.kite.trade/?api_key=\(CommonValues.api_key)&user_id=\(userId)&public_token=\(publicToken)
Step 3 :
After connecting the socket, Subscribe the instrument token using this code
{"a":"subscribe","v":[408065]}
Step 4 :
After subscription, I get the Full Packets using this code
{"a":"mode","v":["full",[408065]]}
At very first time I got the full bytes(168) but after that i can't get full bytes only i am receiving the 1 byte only.
Please help me to achieve this.
Thanks
Pandiyaraj
Did you try during market hours or after market?
You will keep getting 1byte every second once you connect to websocket, you will get data if there is a change in tick data. In other words, you will get data only if the instrument is being traded.
I Checked with both market hours and after market hours too.. I don't know how to identify instrument is Traded or Not?? I don't have knowledge about this .
Are you sure you are not unsubscribing after you get a tick?
In next trading session try subscribing to 408065 and keep logging for a minute.
Which kiteconnect client are you using?
I am using Objective C Client Code based on JAVA Kite Connect. Because i am using in iOS Mobile app development. Based on JAVAKiteConnect , I Write the code for it. I able to get the LTP and OHLC and Instrument token everything.. My problem was sometimes i am getting 168 Bytes and some times only 1 byte heart byte.
That is exactly how it behaves ignore 1 byte and process whatever that is more than that.
Check out parse binary method.
In Market hours i able to got the full bytes, Whereas this instrument token '12866050' i can't get the data bytes.
You didn't get data for NIFTYCPSE17SEPFUT because it was not traded today.
Thanks.. Is this Nifty Futures Right? Segment type NFO-FUT are Nifty Futures and NFO-OPT are Nifty Options . Am i right??
It is the September future contract of CPSE INDEX.
Yes, NFO-FUT is NSE futures segment and NFO-OPT is NSE options segment.
From friday onwards i am getting a 1 Byte data only for this instrument token "12732162" Whereas i am getting the data value in Historical API... What is the issue in that?
NIFTY17JULFUT is ticking. You can check on Kite anytime if you have doubt.
Yes.. "NIFTY17JULFUT" returns no full bytes it returns only 1 byte from socket. Whereas i am getting the full data in Historical API.
It seems to be working fine. Kite also uses the same websocket.
Add the same scrip to marketwatch on Kite and open depth to cross check.
I got the data from socket. I mistakenly added quotes in InstrumentToken that's why i am unable to got the data.. Now working fine.
Thanks for your help