I have integrated Kite API and successfully retrieve public_token. I have opened a socket connection using "Dark web scoket" extension of Google Chrome. When I'm subscribing for quotes using "{"a":"subscribe","v":[408065,884737]}" action, It's going to respond as follows:
Also, when I' using using {"a": "mode", "v": ["ltp", [884737]} action, it's just responding '00', there's no response for given action.
May you please clear about binary data? (I think it's in HEX format) How to parse binary data in JavaScript? Example for using "ltp" mode, because examples given in API documentation is not working.
@dineshkumarc The underlying data is indeed binary, just that it's being displayed by your system as hex. If you are using Javascript, please look up "arraybuffer". You may want to set ws.binaryType = "arraybuffer"
We'll be releasing a Javascript client library shortly that handles all the underlying details for you.
@Kailash is there any specific time interval at which data gets trasnferred to the websocket? Is it tick data? My question is what is the mechanism behind the data transfer in the websocket e.g. time based or per trade based etc?
@instruritesh The API streams messages tick(s) every 700ms to 1 sec. Each message can contain ticks for multiple instruments.
It would be trade based. The exchange may send n number of ticks per instrument per second (usually 5-10 for very active instruments). The API streams the latest one of these ticks in the aforementioned interval.
result's output is \x00\x01\x00,\x00\r\x80\x01\x00\x00\x97T\x00\x00\x002\x00\x00\x00\x00\x00\x00\x0fg\x00\x00#\x05\x00\x00`\x8e\x00\x00\x98X\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x97\xb8
how do i use this ? this looks like hex but it has some characters like ',' in the middle. How can i get quotes from this.
@others let me know in case you guys have a solution for the same.
Hello has there been any update on this? Have u released a javascript API for this? I am getting binary data but I don't know how to convert it back to the required format
I have integrated Kite API and successfully retrieve public_token. I have opened a socket connection using "Dark web scoket" extension of Google Chrome. When I'm subscribing for quotes using "{"a":"subscribe","v":[408065,884737]}" action, It's going to respond as follows:
received: <94B of binary data>
00 02 00 2c 00 06 3a 01 00 01 be 7c 00 00 00 01 |...,..:....|....|
00 01 c0 a8 00 1e f6 da 00 00 00 00 00 00 07 b5 |................|
00 01 bf bc 00 01 c3 8b 00 01 bc 9c 00 01 be 7c |...............||
00 2c 00 0d 80 01 00 00 8a 61 00 00 00 32 00 00 |.,.......a...2..|
88 e0 00 74 98 f2 00 00 00 92 00 00 00 00 00 00 |...t............|
88 22 00 00 8b 06 00 00 86 d3 00 00 8a 61 |."...........a |
Than I'm not going to receive any quotes, May you please help to resolve the issue?
Also, when I' using using {"a": "mode", "v": ["ltp", [884737]} action, it's just responding '00', there's no response for given action.
May you please clear about binary data? (I think it's in HEX format)
How to parse binary data in JavaScript?
Example for using "ltp" mode, because examples given in API documentation is not working.
We'll be releasing a Javascript client library shortly that handles all the underlying details for you.
It would be trade based. The exchange may send n number of ticks per instrument per second (usually 5-10 for very active instruments). The API streams the latest one of these ticks in the aforementioned interval.
import websocket
from settings import *
import json
ws = websocket.create_connection(WEBSOCKET_ROOT+"/?api_key="+API_KEY+"&user_id="+USER_ID+"&public_token="+PUBLIC_TOKEN,sslopt={"cert_reqs": websocket.ssl.CERT_NONE})
message = {"a": "subscribe", "v": [884737]};
ws.send(json.dumps(message))
result = ws.recv()
result's output is \x00\x01\x00,\x00\r\x80\x01\x00\x00\x97T\x00\x00\x002\x00\x00\x00\x00\x00\x00\x0fg\x00\x00#\x05\x00\x00`\x8e\x00\x00\x98X\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x97\xb8
how do i use this ? this looks like hex but it has some characters like ',' in the middle. How can i get quotes from this.
@others let me know in case you guys have a solution for the same.
That said, we're working on client libraries that you can just import and use. The Python and JS libraries should be out in the next few days.
[0, 1, 0, 164, 0, 6, 58, 1, 0, 1, 213, 16, 0, 0, 0, 20, 0, 1, 217, 147, 0, 26, 18, 121, 0, 2, 18, 139, 0, 2, 130, 208, 0, 1, 223, 176, 0, 1, 223, 176, 0, 1, 211, 48, 0, 1, 220, 124, 0, 0, 0, 10, 0, 1, 213, 16, 0, 2, 0, 0, 0, 0, 0, 10, 0, 1, 213, 11, 0, 1, 0, 0, 0, 0, 0, 8, 0, 1, 213, 6, 0, 1, 0, 0, 0, 0, 0, 50, 0, 1, 212, 247, 0, 1, 0, 0, 0, 0, 0, 5, 0, 1, 212, 242, 0, 1, 0, 0, 0, 0, 0, 133, 0, 1, 213, 36, 0, 6, 0, 0, 0, 0, 0, 55, 0, 1, 213, 66, 0, 2, 0, 0, 0, 0, 0, 13, 0, 1, 213, 76, 0, 1, 0, 0, 0, 0, 0, 239, 0, 1, 213, 81, 0, 1, 0, 0, 0, 0, 0, 197, 0, 1, 213, 86, 0, 4, 0, 0]
Can you provide a client library for the Websocket API for Android also? That will help a lot.
Thanks,
Ishwar.
You can check out our official Node.js library. Or if you want a pure js implementation check out this gist.