-
Notifications
You must be signed in to change notification settings - Fork 3
/
binance.js
30 lines (28 loc) · 867 Bytes
/
binance.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const qs = require('querystring')
const crypto = require('crypto')
const Binance = {
init: function(config) {
this.v1URL = 'https://www.binance.com/api/v1/'
this.v3URL = 'https://www.binance.com/api/v3/'
this.secretKey = config.secretKey
this.headers = {
headers: {
'X-MBX-APIKEY': config.apiKey,
'Content-Type': 'application/x-www-form-urlencoded'
}
}
const Public = require('./lib/public')
const Account = require('./lib/account')
const Sockets = require('./lib/websockets')
Object.assign(this, Public, Account, Sockets)
},
sign: function(queryString) {
return '&signature=' + crypto.createHmac('sha256', this.secretKey)
.update(queryString)
.digest('hex')
},
formatQuery: function(queryString) {
return '?' + qs.stringify(queryString)
}
}
module.exports = Binance