You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+55-55Lines changed: 55 additions & 55 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,42 +1,40 @@
1
-
> **NOTICE (Jan 2018): Upgrade to Kite Connect 3.0**
2
-
> This repository is being phased and will be replaced soon by Kite Connect v3. Use the [kite3](https://github.com/zerodhatech/kiteconnectjs/tree/kite3) branch instead. Read the [announcement](https://kite.trade/forum/discussion/2998/upgrade-to-kite-connect-3-0) on the forum.
3
-
4
-
# The Kite Connect API Javascript client
1
+
# The Kite Connect API Javascript client - v3
5
2
The official Javascript node client for communicating with the [Kite Connect API](https://kite.trade).
6
3
7
-
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
4
+
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.
8
5
9
-
[Rainmatter](http://rainmatter.com) (c) 2016. Licensed under the MIT License.
6
+
[Zerodha Technology](http://zerodha.com) (c) 2018. Licensed under the MIT License.
All API calls returns a promise which you can use to call methods like `.then(...)`, `.catch(...)`, and `.finally(...)`.
47
+
All API calls returns a promise which you can use to call methods like `.then(...)`and `.catch(...)`.
50
48
51
49
kiteConnectApiCall
52
50
.then(function(v) {
53
51
// On success
54
52
})
55
53
.catch(function(e) {
56
54
// On rejected
57
-
})
58
-
.finally(function(e) {
59
-
// On finish
60
55
});
61
56
62
-
You can access the full list of [Bluebird Promises API](https://github.com/petkaantonov/bluebird/blob/master/API.md) here.
63
-
64
57
Getting started WebSocket client
65
58
--------------------------------
66
59
var KiteTicker = require("kiteconnect").KiteTicker;
67
-
var ticker = new KiteTicker(api_key, user_id, public_token);
60
+
var ticker = new KiteTicker({
61
+
api_key: "api_key",
62
+
access_token: "access_token"
63
+
});
68
64
69
65
ticker.connect();
70
-
ticker.on("tick", setTick);
66
+
ticker.on("ticks", onTicks);
71
67
ticker.on("connect", subscribe);
72
68
73
-
function setTick(ticks) {
69
+
function onTicks(ticks) {
74
70
console.log("Ticks", ticks);
75
71
}
76
72
@@ -82,54 +78,58 @@ Getting started WebSocket client
82
78
83
79
Auto re-connect WebSocket client
84
80
-------------------------------
85
-
```
86
-
Available from version 1.2
87
-
```
88
-
Optionally you can enable client side auto reconnection to automatically reconnect if the connection is dropped.
81
+
Optionally you can enable client side auto re-connection to automatically reconnect if the connection is dropped.
89
82
It is very useful at times when client side network is unreliable and patchy.
90
83
91
-
All you need to do is enable auto reconnection with preferred interval and time. For example
84
+
All you need to do is enable auto re-connection with preferred interval and time. For example
92
85
93
86
// Enable auto reconnect with 5 second interval and retry for maximum of 20 times.
94
87
ticker.autoReconnect(true, 20, 5)
95
88
96
-
// You can also set reconnection times to -1 for inifinite reconnections
89
+
// You can also set re-connection times to -1 for infinite re-connections
97
90
ticker.autoReconnect(true, -1, 5)
98
91
99
-
- Event `reconnecting` is called when auto reconnection is triggered and event callback carries two additional params `reconnection interval set` and `current reconnection count`.
92
+
- 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`.
100
93
101
-
- Event `noreconnect` is called when number of auto reconnections exceeds the maximum reconnection count set. For example if maximum reconnection count is set as `20` then after 20th reconnection this event will be triggered. Also note that the current process is exited when this event is triggered.
94
+
- 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.
102
95
103
-
- Event `connect` will be triggered again when reconnection succeeds.
96
+
- Event `connect` will be triggered again when re-connection succeeds.
104
97
105
98
Here is an example demonstrating auto reconnection.
106
99
107
-
var KiteTicker = require("kiteconnect").KiteTicker;
108
-
var ticker = new KiteTicker(api_key, user_id, public_token);
100
+
var KiteTicker = require("kiteconnect").KiteTicker;
101
+
var ticker = new KiteTicker({
102
+
api_key: "api_key",
103
+
access_token: "access_token"
104
+
});
109
105
110
-
// set autoreconnect with 10 maximum reconnections and 5 second interval
111
-
ticker.autoReconnect(true, 10, 5)
112
-
ticker.connect();
113
-
ticker.on("tick", setTick);
114
-
ticker.on("connect", subscribe);
106
+
// set autoreconnect with 10 maximum reconnections and 5 second interval
0 commit comments