Unable to connect Kite connect API web sockets

xameeramir
This is my code here being implemented in React Typescript project:
    const ws = new WebSocket(`wss://ws.kite.trade?api_key=XXXXXX&access_token=XXXXXXXXXXX&uid=${(new Date().getTime().toString())}`);

ws.binaryType = 'arraybuffer';
ws.onopen = function (evt) {
// Subscribe to quotes for INFY (408065) and TATAMOTORS (884737)
const message = { "a": "subscribe", "v": [408065, 884737] };
ws.send(JSON.stringify(message));
};

ws.onerror = function (evt) {
console.log('Error', evt)
};

ws.onmessage = (e) => {
var server_message = e.data;
console.log(server_message);
}
I'm trying to connect as shown in the code but getting this error:

WebSocket connection to 'wss://ws.kite.trade/?api_key=XXXXXXXXXXX&access_token=XXXXXXXXXXXXX&uid=1610190561060' failed: Unknown reason

Any help, please?
Tagged:
  • sujith
    One can't display our data on third party websites.
  • sujith
    You can speak to compliance for more information at kiteconnect(at)zerodha.com
  • xameeramir
    If I cannot integrate the web socket API on my website then what is the use of it for us? In what cases can I use the web socket APIs?
  • sujith
    Kite Connect API is provided for personal use only. It can't be used on a third party website.
    If you are developing a platform for mass then you need to check with the compliance team before starting.
    You can reach out to the compliance team in the above-mentioned email.
  • xameeramir
    Okey for personal use only I am trying to connect on localhost and this error is throwing up on localhost itself in my React web project
  • sujith
    It has CORS so you won't be able to use it on a website. You can use it in a non-browser environment.
Sign In or Register to comment.