Nodejs Kiteconnect Client and Websocket Not working

NarenKulkarni
NarenKulkarni edited July 2020 in API clients
I am unable to get Nodejs Kiteconnect client and Websocket running.
import { KiteTicker } from 'kiteconnect';
import { KiteConnect } from 'kiteconnect';

const requestToken = ' '
const apiSecret = '';
const apiKey = '';
const accessToken

let kc = new KiteConnect({
api_key: apiKey
});

kc.generateSession(requestToken, apiSecret).then(session => {
access_token = session.access_token;

}).catch(err => {
console.log(err)
});


let ticker = new KiteTicker({
api_key: apiKey,
access_token: accessToken
});

ticker.autoReconnect(true, 10, 5);
ticker.connect();
ticker.on("ticks", onTicks);
ticker.on("connect", subscribe);

function onTicks(ticks) {
console.log("Ticks", ticks);
}

function subscribe() {
var items = [738561];
ticker.subscribe(items);
ticker.setMode(ticker.modeFull, items);
}



import { KiteTicker } from 'kiteconnect';
^

SyntaxError: Unexpected token {
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
The getting started with API Code Documentation on the Github Nodejs Client doesn't work as well, I have tried getting that to work.
In my attempts at getting it to run, I have -
Changed Node Versions from latest v.14 to previous versions
Added a declaration d.ts file stating Kiteconnect to be a module

Still I am unable to even get the it running


Please do give suggestions on how to sort this out
Sign In or Register to comment.