hollaex-node-lib 2.15.3 → 2.15.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -3
- package/example/hollaex.js +12 -6
- package/kit.js +8 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,12 +12,15 @@ const hollaex = require('hollaex-node-lib');
|
|
|
12
12
|
const client = new hollaex();
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
You can pass
|
|
15
|
+
You can pass custom `apiURL`, `wsURL` and `baseURL` of the HollaEx-Enabled exchange to connect to. `apiURL` is `https://api.hollaex.com` for HollaEx Pro and for your custom exchange it would be something like `https://myexchange.com/api`.
|
|
16
|
+
`wsURL` is the websocket URL for the socket connection and you should pass your stream URL. For HollaEx Pro it is `wss://api.hollaex.com/stream` and for your exchange it would be something like `wss://myexchange.com/stream`.
|
|
17
|
+
|
|
18
|
+
You can also pass your `apiKey` and `apiSecret` generated from the HollaEx-Enabled exchange to use private requests that require authentication. For public endpoints `apiKey` and `apiSecret` are not required.
|
|
16
19
|
|
|
17
20
|
```javascript
|
|
18
21
|
const client = new hollaex({
|
|
19
22
|
apiURL: '<EXCHANGE_API_URL>',
|
|
20
|
-
|
|
23
|
+
wsURL: '<EXCHANGE_WS_URL>',
|
|
21
24
|
apiKey: '<MY_API_KEY>',
|
|
22
25
|
apiSecret: '<MY_API_SECRET>'
|
|
23
26
|
});
|
|
@@ -30,7 +33,7 @@ You can also pass the field `apiExpiresAfter` which is the length of time in sec
|
|
|
30
33
|
```javascript
|
|
31
34
|
const client = new hollaex({
|
|
32
35
|
apiURL: '<EXCHANGE_API_URL>',
|
|
33
|
-
|
|
36
|
+
wsURL: '<EXCHANGE_API_URL>',
|
|
34
37
|
apiKey: '<MY_API_KEY>',
|
|
35
38
|
apiSecret: '<MY_API_SECRET>'
|
|
36
39
|
});
|
package/example/hollaex.js
CHANGED
|
@@ -3,7 +3,13 @@ require('dotenv').load();
|
|
|
3
3
|
|
|
4
4
|
const API_KEY = process.env.API_KEY || '';
|
|
5
5
|
const API_SECRET = process.env.API_SECRET || '';
|
|
6
|
-
const client = new HollaEx({
|
|
6
|
+
const client = new HollaEx({
|
|
7
|
+
apiURL: 'https://api.hollaex.com',
|
|
8
|
+
wsURL: 'wss://api.hollaex.com/stream',
|
|
9
|
+
baseURL: '/v2',
|
|
10
|
+
apiKey: API_KEY,
|
|
11
|
+
apiSecret: API_SECRET
|
|
12
|
+
});
|
|
7
13
|
|
|
8
14
|
client
|
|
9
15
|
.getTicker('xht-usdt')
|
|
@@ -22,12 +28,12 @@ client
|
|
|
22
28
|
symbols : xht-usdt
|
|
23
29
|
*/
|
|
24
30
|
|
|
25
|
-
|
|
31
|
+
client.connect(['orderbook:xht-usdt']);
|
|
26
32
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
client.ws.on('message', (data) => {
|
|
34
|
+
data = JSON.parse(data);
|
|
35
|
+
console.log(data);
|
|
36
|
+
});
|
|
31
37
|
|
|
32
38
|
|
|
33
39
|
|
package/kit.js
CHANGED
|
@@ -4,7 +4,7 @@ const WebSocket = require('ws');
|
|
|
4
4
|
const moment = require('moment');
|
|
5
5
|
const { createRequest, createSignature, generateHeaders, isDatetime, sanitizeDate } = require('./utils');
|
|
6
6
|
const { setWsHeartbeat } = require('ws-heartbeat/client');
|
|
7
|
-
const { each, union, isNumber, isString, isPlainObject, isBoolean, isObject
|
|
7
|
+
const { each, union, isNumber, isString, isPlainObject, isBoolean, isObject } = require('lodash');
|
|
8
8
|
class HollaExKit {
|
|
9
9
|
constructor(
|
|
10
10
|
opts = {
|
|
@@ -27,10 +27,13 @@ class HollaExKit {
|
|
|
27
27
|
};
|
|
28
28
|
this.ws = null;
|
|
29
29
|
const [protocol, endpoint] = this.apiUrl.split('://');
|
|
30
|
-
this.wsUrl =
|
|
31
|
-
|
|
32
|
-
?
|
|
33
|
-
:
|
|
30
|
+
this.wsUrl = (
|
|
31
|
+
opts.wsURL
|
|
32
|
+
? opts.wsURL
|
|
33
|
+
: protocol === 'https'
|
|
34
|
+
? `wss://${endpoint}/stream`
|
|
35
|
+
: `ws://${endpoint}/stream`
|
|
36
|
+
);
|
|
34
37
|
this.wsEvents = [];
|
|
35
38
|
this.wsReconnect = true;
|
|
36
39
|
this.wsReconnectInterval = 5000;
|