The official typescript client library for the Kite Connect trading APIs
The official typescript client library for the Kite Connect trading APIs
The official TypeScript/JavaScript for communicating with the Kite Connect API.
Kite Connect is a set of REST-like APIs that expose many capabilities required to build a complete investment and trading platform. Execute orders in real time, manage user portfolio, stream live market data (WebSockets), and more, with the simple HTTP API collection.
Zerodha Technology (c) 2024. Licensed under the MIT License.
Install via npm
npm install kiteconnect@latestOr via yarn
yarn add kiteconnect……Optionally, you can enable client-side auto re-connection to automatically reconnect if the connection is dropped. It is very useful when the client-side network is unreliable and patchy.
Enable auto re-connection with a preferred interval and time. For example:
// Enable auto reconnect with 5 second interval and retry for maximum of 20 times.
ticker.autoReconnect(true, 20, 5);
// You can also set re-connection times to -1 for infinite re-connections
ticker.autoReconnect(true, -1, 5);Event reconnecting is called when auto re-connection is triggered and event callback carries two additional params reconnection interval set and current re-connection count.
Event noreconnect is called when number of auto re-connections exceeds the maximum re-connection count set. For example if maximum re-connection count is set as 20 then after 20th re-connection this event will be triggered. Also note that the current process is exited when this event is triggered.
Event connect will be triggered again when re-connection succeeds.
Here is an example demonstrating auto reconnection.
…npm run test$ npm install typedoc --save-dev
$ npx typedoc --out ./docsIn a typical web application where a new instance of views, controllers etc. are created per incoming HTTP request, you will need to initialise a new instance of Kite client per request as well. This is because each individual instance represents a single user that's authenticated, unlike an admin API where you may use one instance to manage many users.
Hence, in your web application, typically:
login_url()request_token from the query parametersrequest_access_token() to obtain the access_token
along with authenticated user dataaccess_token and initialise instances
of Kite client for subsequent API calls.No open issues yet, or sync has not completed.