kucoin-api 0.0.3 → 1.0.0
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 +219 -828
- package/dist/cjs/FuturesClient.d.ts +246 -0
- package/dist/cjs/FuturesClient.js +261 -0
- package/dist/cjs/FuturesClient.js.map +1 -0
- package/dist/cjs/SpotClient.d.ts +692 -0
- package/dist/cjs/SpotClient.js +745 -0
- package/dist/cjs/SpotClient.js.map +1 -0
- package/dist/cjs/WebsocketClient.d.ts +77 -0
- package/dist/cjs/WebsocketClient.js +337 -0
- package/dist/cjs/WebsocketClient.js.map +1 -0
- package/dist/cjs/index.d.ts +22 -0
- package/dist/cjs/index.js +39 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/lib/BaseRestClient.d.ts +42 -0
- package/dist/cjs/lib/BaseRestClient.js +268 -0
- package/dist/cjs/lib/BaseRestClient.js.map +1 -0
- package/dist/cjs/lib/BaseWSClient.d.ts +168 -0
- package/dist/cjs/lib/BaseWSClient.js +622 -0
- package/dist/cjs/lib/BaseWSClient.js.map +1 -0
- package/dist/cjs/lib/misc-util.d.ts +1 -0
- package/dist/cjs/lib/misc-util.js +8 -0
- package/dist/cjs/lib/misc-util.js.map +1 -0
- package/dist/cjs/lib/requestUtils.d.ts +35 -0
- package/dist/cjs/lib/requestUtils.js +54 -0
- package/dist/cjs/lib/requestUtils.js.map +1 -0
- package/dist/cjs/lib/webCryptoAPI.d.ts +10 -0
- package/dist/cjs/lib/webCryptoAPI.js +57 -0
- package/dist/cjs/lib/webCryptoAPI.js.map +1 -0
- package/dist/cjs/lib/websocket/WsStore.d.ts +63 -0
- package/dist/cjs/lib/websocket/WsStore.js +254 -0
- package/dist/cjs/lib/websocket/WsStore.js.map +1 -0
- package/dist/cjs/lib/websocket/WsStore.types.d.ts +50 -0
- package/dist/cjs/lib/websocket/WsStore.types.js +14 -0
- package/dist/cjs/lib/websocket/WsStore.types.js.map +1 -0
- package/dist/cjs/lib/websocket/logger.d.ts +6 -0
- package/dist/cjs/lib/websocket/logger.js +16 -0
- package/dist/cjs/lib/websocket/logger.js.map +1 -0
- package/dist/cjs/lib/websocket/websocket-util.d.ts +30 -0
- package/dist/cjs/lib/websocket/websocket-util.js +19 -0
- package/dist/cjs/lib/websocket/websocket-util.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/types/request/futures.types.d.ts +183 -0
- package/dist/cjs/types/request/futures.types.js +7 -0
- package/dist/cjs/types/request/futures.types.js.map +1 -0
- package/dist/cjs/types/request/spot-account.d.ts +56 -0
- package/dist/cjs/types/request/spot-account.js +3 -0
- package/dist/cjs/types/request/spot-account.js.map +1 -0
- package/dist/cjs/types/request/spot-earn.d.ts +27 -0
- package/dist/cjs/types/request/spot-earn.js +8 -0
- package/dist/cjs/types/request/spot-earn.js.map +1 -0
- package/dist/cjs/types/request/spot-funding.d.ts +88 -0
- package/dist/cjs/types/request/spot-funding.js +10 -0
- package/dist/cjs/types/request/spot-funding.js.map +1 -0
- package/dist/cjs/types/request/spot-margin-trading.d.ts +169 -0
- package/dist/cjs/types/request/spot-margin-trading.js +10 -0
- package/dist/cjs/types/request/spot-margin-trading.js.map +1 -0
- package/dist/cjs/types/request/spot-trading.d.ts +214 -0
- package/dist/cjs/types/request/spot-trading.js +10 -0
- package/dist/cjs/types/request/spot-trading.js.map +1 -0
- package/dist/cjs/types/response/futures.types.d.ts +501 -0
- package/dist/cjs/types/response/futures.types.js +7 -0
- package/dist/cjs/types/response/futures.types.js.map +1 -0
- package/dist/cjs/types/response/shared.types.d.ts +9 -0
- package/dist/cjs/types/response/shared.types.js +3 -0
- package/dist/cjs/types/response/shared.types.js.map +1 -0
- package/dist/cjs/types/response/spot-account.d.ts +140 -0
- package/dist/cjs/types/response/spot-account.js +3 -0
- package/dist/cjs/types/response/spot-account.js.map +1 -0
- package/dist/cjs/types/response/spot-earn.d.ts +74 -0
- package/dist/cjs/types/response/spot-earn.js +8 -0
- package/dist/cjs/types/response/spot-earn.js.map +1 -0
- package/dist/cjs/types/response/spot-funding.d.ts +176 -0
- package/dist/cjs/types/response/spot-funding.js +10 -0
- package/dist/cjs/types/response/spot-funding.js.map +1 -0
- package/dist/cjs/types/response/spot-margin-trading.d.ts +257 -0
- package/dist/cjs/types/response/spot-margin-trading.js +10 -0
- package/dist/cjs/types/response/spot-margin-trading.js.map +1 -0
- package/dist/cjs/types/response/spot-trading.d.ts +388 -0
- package/dist/cjs/types/response/spot-trading.js +10 -0
- package/dist/cjs/types/response/spot-trading.js.map +1 -0
- package/dist/cjs/types/response/spot-vip.d.ts +38 -0
- package/dist/cjs/types/response/spot-vip.js +10 -0
- package/dist/cjs/types/response/spot-vip.js.map +1 -0
- package/dist/cjs/types/response/ws.d.ts +11 -0
- package/dist/cjs/types/response/ws.js +3 -0
- package/dist/cjs/types/response/ws.js.map +1 -0
- package/dist/cjs/types/websockets/client.d.ts +46 -0
- package/dist/cjs/types/websockets/client.js +3 -0
- package/dist/cjs/types/websockets/client.js.map +1 -0
- package/dist/cjs/types/websockets/events.d.ts +5 -0
- package/dist/cjs/types/websockets/events.js +3 -0
- package/dist/cjs/types/websockets/events.js.map +1 -0
- package/dist/cjs/types/websockets/requests.d.ts +8 -0
- package/dist/cjs/types/websockets/requests.js +3 -0
- package/dist/cjs/types/websockets/requests.js.map +1 -0
- package/dist/cjs/types/websockets/wsAPI.d.ts +9 -0
- package/dist/cjs/types/websockets/wsAPI.js +3 -0
- package/dist/cjs/types/websockets/wsAPI.js.map +1 -0
- package/dist/mjs/FuturesClient.d.ts +246 -0
- package/dist/mjs/FuturesClient.js +257 -0
- package/dist/mjs/FuturesClient.js.map +1 -0
- package/dist/mjs/SpotClient.d.ts +692 -0
- package/dist/mjs/SpotClient.js +741 -0
- package/dist/mjs/SpotClient.js.map +1 -0
- package/dist/mjs/WebsocketClient.d.ts +77 -0
- package/dist/mjs/WebsocketClient.js +333 -0
- package/dist/mjs/WebsocketClient.js.map +1 -0
- package/dist/mjs/index.d.ts +22 -0
- package/dist/mjs/index.js +23 -0
- package/dist/mjs/index.js.map +1 -0
- package/dist/mjs/lib/BaseRestClient.d.ts +42 -0
- package/dist/mjs/lib/BaseRestClient.js +261 -0
- package/dist/mjs/lib/BaseRestClient.js.map +1 -0
- package/dist/mjs/lib/BaseWSClient.d.ts +168 -0
- package/dist/mjs/lib/BaseWSClient.js +615 -0
- package/dist/mjs/lib/BaseWSClient.js.map +1 -0
- package/dist/mjs/lib/misc-util.d.ts +1 -0
- package/dist/mjs/lib/misc-util.js +4 -0
- package/dist/mjs/lib/misc-util.js.map +1 -0
- package/dist/mjs/lib/requestUtils.d.ts +35 -0
- package/dist/mjs/lib/requestUtils.js +49 -0
- package/dist/mjs/lib/requestUtils.js.map +1 -0
- package/dist/mjs/lib/webCryptoAPI.d.ts +10 -0
- package/dist/mjs/lib/webCryptoAPI.js +52 -0
- package/dist/mjs/lib/webCryptoAPI.js.map +1 -0
- package/dist/mjs/lib/websocket/WsStore.d.ts +63 -0
- package/dist/mjs/lib/websocket/WsStore.js +249 -0
- package/dist/mjs/lib/websocket/WsStore.js.map +1 -0
- package/dist/mjs/lib/websocket/WsStore.types.d.ts +50 -0
- package/dist/mjs/lib/websocket/WsStore.types.js +11 -0
- package/dist/mjs/lib/websocket/WsStore.types.js.map +1 -0
- package/dist/mjs/lib/websocket/logger.d.ts +6 -0
- package/dist/mjs/lib/websocket/logger.js +13 -0
- package/dist/mjs/lib/websocket/logger.js.map +1 -0
- package/dist/mjs/lib/websocket/websocket-util.d.ts +30 -0
- package/dist/mjs/lib/websocket/websocket-util.js +15 -0
- package/dist/mjs/lib/websocket/websocket-util.js.map +1 -0
- package/dist/mjs/package.json +3 -0
- package/dist/mjs/types/request/futures.types.d.ts +183 -0
- package/dist/mjs/types/request/futures.types.js +6 -0
- package/dist/mjs/types/request/futures.types.js.map +1 -0
- package/dist/mjs/types/request/spot-account.d.ts +56 -0
- package/dist/mjs/types/request/spot-account.js +2 -0
- package/dist/mjs/types/request/spot-account.js.map +1 -0
- package/dist/mjs/types/request/spot-earn.d.ts +27 -0
- package/dist/mjs/types/request/spot-earn.js +7 -0
- package/dist/mjs/types/request/spot-earn.js.map +1 -0
- package/dist/mjs/types/request/spot-funding.d.ts +88 -0
- package/dist/mjs/types/request/spot-funding.js +9 -0
- package/dist/mjs/types/request/spot-funding.js.map +1 -0
- package/dist/mjs/types/request/spot-margin-trading.d.ts +169 -0
- package/dist/mjs/types/request/spot-margin-trading.js +9 -0
- package/dist/mjs/types/request/spot-margin-trading.js.map +1 -0
- package/dist/mjs/types/request/spot-trading.d.ts +214 -0
- package/dist/mjs/types/request/spot-trading.js +9 -0
- package/dist/mjs/types/request/spot-trading.js.map +1 -0
- package/dist/mjs/types/response/futures.types.d.ts +501 -0
- package/dist/mjs/types/response/futures.types.js +6 -0
- package/dist/mjs/types/response/futures.types.js.map +1 -0
- package/dist/mjs/types/response/shared.types.d.ts +9 -0
- package/dist/mjs/types/response/shared.types.js +2 -0
- package/dist/mjs/types/response/shared.types.js.map +1 -0
- package/dist/mjs/types/response/spot-account.d.ts +140 -0
- package/dist/mjs/types/response/spot-account.js +2 -0
- package/dist/mjs/types/response/spot-account.js.map +1 -0
- package/dist/mjs/types/response/spot-earn.d.ts +74 -0
- package/dist/mjs/types/response/spot-earn.js +7 -0
- package/dist/mjs/types/response/spot-earn.js.map +1 -0
- package/dist/mjs/types/response/spot-funding.d.ts +176 -0
- package/dist/mjs/types/response/spot-funding.js +9 -0
- package/dist/mjs/types/response/spot-funding.js.map +1 -0
- package/dist/mjs/types/response/spot-margin-trading.d.ts +257 -0
- package/dist/mjs/types/response/spot-margin-trading.js +9 -0
- package/dist/mjs/types/response/spot-margin-trading.js.map +1 -0
- package/dist/mjs/types/response/spot-trading.d.ts +388 -0
- package/dist/mjs/types/response/spot-trading.js +9 -0
- package/dist/mjs/types/response/spot-trading.js.map +1 -0
- package/dist/mjs/types/response/spot-vip.d.ts +38 -0
- package/dist/mjs/types/response/spot-vip.js +9 -0
- package/dist/mjs/types/response/spot-vip.js.map +1 -0
- package/dist/mjs/types/response/ws.d.ts +11 -0
- package/dist/mjs/types/response/ws.js +2 -0
- package/dist/mjs/types/response/ws.js.map +1 -0
- package/dist/mjs/types/websockets/client.d.ts +46 -0
- package/dist/mjs/types/websockets/client.js +2 -0
- package/dist/mjs/types/websockets/client.js.map +1 -0
- package/dist/mjs/types/websockets/events.d.ts +5 -0
- package/dist/mjs/types/websockets/events.js +2 -0
- package/dist/mjs/types/websockets/events.js.map +1 -0
- package/dist/mjs/types/websockets/requests.d.ts +8 -0
- package/dist/mjs/types/websockets/requests.js +2 -0
- package/dist/mjs/types/websockets/requests.js.map +1 -0
- package/dist/mjs/types/websockets/wsAPI.d.ts +9 -0
- package/dist/mjs/types/websockets/wsAPI.js +2 -0
- package/dist/mjs/types/websockets/wsAPI.js.map +1 -0
- package/package.json +70 -14
- package/LICENSE +0 -21
- package/index.js +0 -854
- package/test.js +0 -133
package/index.js
DELETED
|
@@ -1,854 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const clients = require('restify-clients')
|
|
4
|
-
const crypto = require('crypto')
|
|
5
|
-
const Q = require('q')
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* A Node.js client for the KuCoin API.
|
|
9
|
-
* @class
|
|
10
|
-
* @version 0.0.2
|
|
11
|
-
* @param {string} apiKey Your KuCoin API Key.
|
|
12
|
-
* @param {string} apiSecret Your KuCoin API Secret.
|
|
13
|
-
* @example
|
|
14
|
-
* let kc = new Kucoin();
|
|
15
|
-
*/
|
|
16
|
-
class Kucoin {
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* You'll need to provide your KuCoin API key and secret.
|
|
20
|
-
* @param {string} apiKey Your KuCoin API Key.
|
|
21
|
-
* @param {string} apiSecret Your KuCoin API Secret.
|
|
22
|
-
*/
|
|
23
|
-
constructor(apiKey, apiSecret) {
|
|
24
|
-
this._apiKey = apiKey
|
|
25
|
-
this._apiSecret = apiSecret
|
|
26
|
-
this.client = clients.createJsonClient({
|
|
27
|
-
url: 'https://api.kucoin.com'
|
|
28
|
-
})
|
|
29
|
-
this.path_prefix = '/v1'
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Send the request to the KuCoin API, sign if authorisation is required.
|
|
34
|
-
* @access private
|
|
35
|
-
* @param {string} method HTTP request method, either 'get' or 'post'.
|
|
36
|
-
* @param {string} endpoint API endpoint URL suffix.
|
|
37
|
-
* @param {boolean} [signed=false] Whether this endpoint requires authentiation.
|
|
38
|
-
* @param {Object} params Any parameters for the request.
|
|
39
|
-
* @return {Promise} An object containing the API response.
|
|
40
|
-
*/
|
|
41
|
-
rawRequest(method, endpoint, signed = false, params) {
|
|
42
|
-
let deferred = Q.defer()
|
|
43
|
-
let path = this.path_prefix + endpoint
|
|
44
|
-
let nonce = new Date().getTime()
|
|
45
|
-
let queryString
|
|
46
|
-
if (params !== undefined) {
|
|
47
|
-
queryString = [];
|
|
48
|
-
for (let key in params) {
|
|
49
|
-
queryString.push(key + '=' + params[key])
|
|
50
|
-
}
|
|
51
|
-
queryString.sort()
|
|
52
|
-
queryString = queryString.join('&')
|
|
53
|
-
} else {
|
|
54
|
-
queryString = ''
|
|
55
|
-
}
|
|
56
|
-
let options = {
|
|
57
|
-
path: path + (queryString ? '?' + queryString : ''),
|
|
58
|
-
headers: {}
|
|
59
|
-
}
|
|
60
|
-
if (signed) {
|
|
61
|
-
options.headers = {
|
|
62
|
-
'Content-Type': 'application/json',
|
|
63
|
-
'KC-API-KEY': this._apiKey,
|
|
64
|
-
'KC-API-NONCE': nonce,
|
|
65
|
-
'KC-API-SIGNATURE': this.getSignature(path, queryString, nonce)
|
|
66
|
-
}
|
|
67
|
-
} else {
|
|
68
|
-
options.headers = {
|
|
69
|
-
'Content-Type': 'application/json'
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (method == 'post') {
|
|
73
|
-
this.client.post(options, {}, (err, req, res, obj) => {
|
|
74
|
-
if (err || !obj.success) {
|
|
75
|
-
if (!err && !obj.success) {
|
|
76
|
-
err = obj
|
|
77
|
-
}
|
|
78
|
-
deferred.reject(err)
|
|
79
|
-
} else {
|
|
80
|
-
deferred.resolve(obj)
|
|
81
|
-
}
|
|
82
|
-
})
|
|
83
|
-
} else {
|
|
84
|
-
this.client.get(options, (err, req, res, obj) => {
|
|
85
|
-
if (err || !obj.success) {
|
|
86
|
-
if (!err && !obj.success) {
|
|
87
|
-
err = obj
|
|
88
|
-
}
|
|
89
|
-
deferred.reject(err)
|
|
90
|
-
} else {
|
|
91
|
-
deferred.resolve(obj)
|
|
92
|
-
}
|
|
93
|
-
})
|
|
94
|
-
}
|
|
95
|
-
return deferred.promise
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Generate a signature to sign API requests that require authorisation.
|
|
100
|
-
* @access private
|
|
101
|
-
* @param {string} path API endpoint URL suffix.
|
|
102
|
-
* @param {string} queryString A querystring of parameters for the request.
|
|
103
|
-
* @param {number} nonce Number of milliseconds since the Unix epoch.
|
|
104
|
-
* @return {string} A string to be used as the authorisation signature.
|
|
105
|
-
*/
|
|
106
|
-
getSignature(path, queryString, nonce) {
|
|
107
|
-
let strForSign = path + '/' + nonce + '/' + queryString
|
|
108
|
-
let signatureStr = new Buffer(strForSign).toString('base64')
|
|
109
|
-
let signatureResult = crypto.createHmac('sha256', this._apiSecret)
|
|
110
|
-
.update(signatureStr)
|
|
111
|
-
.digest('hex')
|
|
112
|
-
return signatureResult
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Do a standard public request.
|
|
117
|
-
* @access private
|
|
118
|
-
* @param {string} method HTTP request method, either 'get' or 'post'.
|
|
119
|
-
* @param {string} endpoint API endpoint URL suffix.
|
|
120
|
-
* @param {Object} params Any parameters for the request.
|
|
121
|
-
* @return {Promise} An object containing the API response.
|
|
122
|
-
*/
|
|
123
|
-
doRequest(method, endpoint, params) {
|
|
124
|
-
return this.rawRequest(method, endpoint, false, params)
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Do a signed private request.
|
|
129
|
-
* @access private
|
|
130
|
-
* @param {string} method HTTP request method, either 'get' or 'post'.
|
|
131
|
-
* @param {string} endpoint API endpoint URL suffix.
|
|
132
|
-
* @param {Object} params Any parameters for the request.
|
|
133
|
-
* @return {Promise} An object containing the API response.
|
|
134
|
-
*/
|
|
135
|
-
doSignedRequest(method, endpoint, params) {
|
|
136
|
-
return this.rawRequest(method, endpoint, true, params)
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Retrieve exchange rates for coins.
|
|
141
|
-
* @access public
|
|
142
|
-
* @param {{symbols: string[]}} [params] An Array of symbols, or if blank BTC will be returned.
|
|
143
|
-
* @return {Promise} An object containing the API response.
|
|
144
|
-
* @example <caption>Specify one or more symbols:</caption>
|
|
145
|
-
* kc.getExchangeRates({
|
|
146
|
-
* symbols: ['NEO','GAS']
|
|
147
|
-
* }).then(console.log).catch(console.error)
|
|
148
|
-
*
|
|
149
|
-
* // Returns:
|
|
150
|
-
*
|
|
151
|
-
* {
|
|
152
|
-
* "success": true,
|
|
153
|
-
* "code": "OK",
|
|
154
|
-
* "msg": "Operation succeeded.",
|
|
155
|
-
* "timestamp": 1509589905631,
|
|
156
|
-
* "data": {
|
|
157
|
-
* "currencies": [["USD", "$"], ["EUR", "€"], ["AUD", "$"], ["CAD", "$"], ["CHF", "CHF"], ["CNY", "¥"], ["GBP", "£"], ["JPY", "¥"], ["NZD", "$"], ["BGN", "лв."], ["BRL", "R$"], ["CZK", "Kč"], ["DKK", "kr"], ["HKD", "$"], ["HRK", "kn"], ["HUF", "Ft"], ["IDR", "Rp"], ["ILS", "₪"], ["INR", "₹"], ["KRW", "₩"], ["MXN", "$"], ["MYR", "RM"], ["NOK", "kr"], ["PHP", "₱"], ["PLN", "zł"], ["RON", "lei"], ["RUB", "₽"], ["SEK", "kr"], ["SGD", "$"], ["THB", "฿"], ["TRY", "₺"], ["ZAR", "R"]],
|
|
158
|
-
* "rates": {
|
|
159
|
-
* "GAS": { "CHF": 14.57, "HRK": 94.19, "MXN": 279.02, "ZAR": 205.31, "INR": 939.59, "CNY": 96.15, "THB": 482.3, "AUD": 18.95, "ILS": 51.16, "KRW": 16176.81, "JPY": 1660.88, "PLN": 53.03, "GBP": 10.94, "IDR": 197577.69, "HUF": 3904.86, "PHP": 751.63, "TRY": 55.6, "RUB": 845.61, "HKD": 113.47, "EUR": 12.52, "DKK": 93.21, "USD": 14.54, "CAD": 18.77, "MYR": 61.54, "BGN": 24.49, "NOK": 118.5, "RON": 57.66, "SGD": 19.8, "CZK": 320.11, "SEK": 122.16, "NZD": 21.12, "BRL": 47.78
|
|
160
|
-
* },
|
|
161
|
-
* "NEO": {
|
|
162
|
-
* "CHF": 25.33, "HRK": 163.66, "MXN": 484.81, "ZAR": 356.73, "INR": 1632.55, "CNY": 167.07, "THB": 838.01, "AUD": 32.94, "ILS": 88.89, "KRW": 28107.31, "JPY": 2885.78, "PLN": 92.14, "GBP": 19.01, "IDR": 343292.4, "HUF": 6784.72, "PHP": 1305.97, "TRY": 96.61, "RUB": 1469.25, "HKD": 197.16, "EUR": 21.76, "DKK": 161.95, "USD": 25.27, "CAD": 32.61, "MYR": 106.93, "BGN": 42.56, "NOK": 205.9, "RON": 100.18, "SGD": 34.4, "CZK": 556.2, "SEK": 212.27, "NZD": 36.7, "BRL": 83.02
|
|
163
|
-
* }
|
|
164
|
-
* }
|
|
165
|
-
* }
|
|
166
|
-
* }
|
|
167
|
-
* @example <caption>Retrieve data for BTC by default:</caption>
|
|
168
|
-
* kc.getExchangeRates().then(console.log).catch(console.error)
|
|
169
|
-
*
|
|
170
|
-
* // Returns:
|
|
171
|
-
*
|
|
172
|
-
* {
|
|
173
|
-
* "success": true,
|
|
174
|
-
* "code": "OK",
|
|
175
|
-
* "msg": "Operation succeeded.",
|
|
176
|
-
* "timestamp": 1509590207497,
|
|
177
|
-
* "data": {
|
|
178
|
-
* "rates": {
|
|
179
|
-
* "BTC": { "CHF": 6817.62, "HRK": 44045.89, "MXN": 130476.13, "ZAR": 96007.15, "INR": 439363.98, "CNY": 44963.39, "THB": 225531.1, "AUD": 8865.49, "ILS": 23923.57, "KRW": 7564405.86, "JPY": 776640.44, "PLN": 24798.21, "GBP": 5118.25, "IDR": 92388859.2, "HUF": 1825945.01, "PHP": 351470.78, "TRY": 26002.05, "RUB": 395413.97, "HKD": 53061.7, "EUR": 5857.14, "DKK": 43586.13, "USD": 6801.3, "CAD": 8777.75, "MYR": 28779.7, "BGN": 11455.42, "NOK": 55414.27, "RON": 26962.39, "SGD": 9259.28, "CZK": 149689.81, "SEK": 57127.51, "NZD": 9878.88, "BRL": 22344.99
|
|
180
|
-
* }
|
|
181
|
-
* },
|
|
182
|
-
* "currencies": [["USD", "$"], ["EUR", "€"], ["AUD", "$"], ["CAD", "$"], ["CHF", "CHF"], ["CNY", "¥"], ["GBP", "£"], ["JPY", "¥"], ["NZD", "$"], ["BGN", "лв."], ["BRL", "R$"], ["CZK", "Kč"], ["DKK", "kr"], ["HKD", "$"], ["HRK", "kn"], ["HUF", "Ft"], ["IDR", "Rp"], ["ILS", "₪"], ["INR", "₹"], ["KRW", "₩"], ["MXN", "$"], ["MYR", "RM"], ["NOK", "kr"], ["PHP", "₱"], ["PLN", "zł"], ["RON", "lei"], ["RUB", "₽"], ["SEK", "kr"], ["SGD", "$"], ["THB", "฿"], ["TRY", "₺"], ["ZAR", "R"]]
|
|
183
|
-
* }
|
|
184
|
-
* }
|
|
185
|
-
*/
|
|
186
|
-
getExchangeRates(params = {}) {
|
|
187
|
-
params.coins = (params.symbols ? params.symbols.join(',') : '')
|
|
188
|
-
return this.doRequest('get', '/open/currencies', params)
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Retrieve a list of supported languages.
|
|
193
|
-
* @access public
|
|
194
|
-
* @return {Promise} An object containing the API response.
|
|
195
|
-
* @example
|
|
196
|
-
* kc.getLanguages().then(console.log).catch(console.error)
|
|
197
|
-
*
|
|
198
|
-
* // Returns:
|
|
199
|
-
*
|
|
200
|
-
* {
|
|
201
|
-
* "success": true,
|
|
202
|
-
* "code": "OK",
|
|
203
|
-
* "msg": "Operation succeeded.",
|
|
204
|
-
* "timestamp": 1509590811348,
|
|
205
|
-
* "data": [["zh_CN", "中文简体", true], ["zh_HK", "中文繁体", true], ["en_US", "English", true], ["ja_JP", "日本語", true], ["ru_RU", "русский", true], ["pt_PT", "Portugues", true], ["de_DE", "Deutsch", true], ["nl_NL", "Nederlands", true], ["ko_KR", "한국어", true], ["fr_FR", "Français", true], ["es_ES", "Español", false]]
|
|
206
|
-
* }
|
|
207
|
-
*/
|
|
208
|
-
getLanguages() {
|
|
209
|
-
return this.doRequest('get', '/open/lang-list')
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Change the language for your account.
|
|
214
|
-
* @access public
|
|
215
|
-
* @param {{lang: string}} params The specific language locale to change to from the list provided by getLanguages.
|
|
216
|
-
* @return {Promise} An object containing the API response.
|
|
217
|
-
* @example
|
|
218
|
-
* kc.changeLanguage({
|
|
219
|
-
* lang: 'en_US'
|
|
220
|
-
* }).then(console.log).catch(console.error)
|
|
221
|
-
*
|
|
222
|
-
* // Returns:
|
|
223
|
-
*
|
|
224
|
-
* {
|
|
225
|
-
* "success": true,
|
|
226
|
-
* "code": "OK",
|
|
227
|
-
* "msg": "Operation succeeded.",
|
|
228
|
-
* "timestamp": 1509590866149,
|
|
229
|
-
* "data": null
|
|
230
|
-
* }
|
|
231
|
-
*/
|
|
232
|
-
changeLanguage(params = {}) {
|
|
233
|
-
return this.doSignedRequest('post', '/user/change-lang', params)
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Get account information for the authenticated user.
|
|
238
|
-
* @access public
|
|
239
|
-
* @return {Promise} An object containing the API response.
|
|
240
|
-
* @example
|
|
241
|
-
* kc.getUserInfo().then(console.log).catch(console.error)
|
|
242
|
-
*
|
|
243
|
-
* // Returns:
|
|
244
|
-
*
|
|
245
|
-
* {
|
|
246
|
-
* "success": true,
|
|
247
|
-
* "code": "OK",
|
|
248
|
-
* "msg": "Operation succeeded.",
|
|
249
|
-
* "timestamp": 1509590943414,
|
|
250
|
-
* "data": {
|
|
251
|
-
* "referrer_code": "XXXXXX",
|
|
252
|
-
* "photoCredentialValidated": false,
|
|
253
|
-
* "videoValidated": false,
|
|
254
|
-
* "language": "en_US",
|
|
255
|
-
* "csrf": "XXXXXXXXXXXXXXXXXXXXXXX=",
|
|
256
|
-
* "oid": "xxxxxxxxxxxxxxxxxxxxxxxx",
|
|
257
|
-
* "baseFeeRate": 1,
|
|
258
|
-
* "hasCredential": false,
|
|
259
|
-
* "phoneValidated": true,
|
|
260
|
-
* "phone": "",
|
|
261
|
-
* "credentialValidated": false,
|
|
262
|
-
* "googleTwoFaBinding": true,
|
|
263
|
-
* "nickname": null,
|
|
264
|
-
* "name": "",
|
|
265
|
-
* "hasTradePassword": false,
|
|
266
|
-
* "currency": null,
|
|
267
|
-
* "emailValidated": true,
|
|
268
|
-
* "email": "hello@example.com"
|
|
269
|
-
* }
|
|
270
|
-
* }
|
|
271
|
-
*/
|
|
272
|
-
getUserInfo() {
|
|
273
|
-
return this.doSignedRequest('get', '/user/info')
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Get the number of invitees from the authenticated user's referral code.
|
|
278
|
-
* @access public
|
|
279
|
-
* @return {Promise} An object containing the API response.
|
|
280
|
-
* @example
|
|
281
|
-
* kc.getInviteCount().then(console.log).catch(console.error)
|
|
282
|
-
*
|
|
283
|
-
* // Returns:
|
|
284
|
-
*
|
|
285
|
-
* {
|
|
286
|
-
* "success": true,
|
|
287
|
-
* "code": "OK",
|
|
288
|
-
* "msg": "Operation succeeded.",
|
|
289
|
-
* "timestamp": 1509591130780,
|
|
290
|
-
* "data": {
|
|
291
|
-
* "countThree": 0,
|
|
292
|
-
* "count": 0,
|
|
293
|
-
* "countTwo": 0
|
|
294
|
-
* }
|
|
295
|
-
* }
|
|
296
|
-
*/
|
|
297
|
-
getInviteCount() {
|
|
298
|
-
return this.doSignedRequest('get', '/referrer/descendant/count')
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* Get promotion reward info.
|
|
303
|
-
* @access public
|
|
304
|
-
* @param {{symbol: string}} [params] The coin's symbol to retrieve reward info for.
|
|
305
|
-
* @return {Promise} An object containing the API response.
|
|
306
|
-
* @example <caption>Specify a symbol:</caption>
|
|
307
|
-
* kc.getPromotionRewardInfo({
|
|
308
|
-
* symbol: 'NEO'
|
|
309
|
-
* }).then(console.log).catch(console.error)
|
|
310
|
-
* @example <caption>Retrieve data for all symbols:</caption>
|
|
311
|
-
* kc.getPromotionRewardInfo().then(console.log).catch(console.error)
|
|
312
|
-
*
|
|
313
|
-
* // Returns:
|
|
314
|
-
*
|
|
315
|
-
* {
|
|
316
|
-
* "success": true,
|
|
317
|
-
* "code": "OK",
|
|
318
|
-
* "msg": "Operation succeeded.",
|
|
319
|
-
* "timestamp": 1509591205512,
|
|
320
|
-
* "data": {
|
|
321
|
-
* "grantCountDownSeconds": 219994,
|
|
322
|
-
* "drawingCount": 0,
|
|
323
|
-
* "assignedCount": 0
|
|
324
|
-
* }
|
|
325
|
-
* }
|
|
326
|
-
*/
|
|
327
|
-
getPromotionRewardInfo(params = {}) {
|
|
328
|
-
params.coin = (params.symbol ? params.symbol : '')
|
|
329
|
-
return this.doSignedRequest('get', '/account/' + (params.symbol != undefined ? params.symbol + '/' : '') + 'promotion/info', params)
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* Get promotion reward summary.
|
|
334
|
-
* @access public
|
|
335
|
-
* @param {{symbol: string}} [params] The coin's symbol to retrieve reward summary for.
|
|
336
|
-
* @return {Promise} An object containing the API response.
|
|
337
|
-
* @example <caption>Specify a symbol:</caption>
|
|
338
|
-
* kc.getPromotionRewardSummary({
|
|
339
|
-
* symbol: 'NEO'
|
|
340
|
-
* }).then(console.log).catch(console.error)
|
|
341
|
-
* @example <caption>Retrieve data for all symbols:</caption>
|
|
342
|
-
* kc.getPromotionRewardSummary().then(console.log).catch(console.error)
|
|
343
|
-
*
|
|
344
|
-
* // Returns:
|
|
345
|
-
*
|
|
346
|
-
* {
|
|
347
|
-
* "success": true,
|
|
348
|
-
* "code": "OK",
|
|
349
|
-
* "msg": "Operation succeeded.",
|
|
350
|
-
* "timestamp": 1509591324280,
|
|
351
|
-
* "data": []
|
|
352
|
-
* }
|
|
353
|
-
*/
|
|
354
|
-
getPromotionRewardSummary(params = {}) {
|
|
355
|
-
params.coin = (params.symbol ? params.symbol : '')
|
|
356
|
-
return this.doSignedRequest('get', '/account/' + (params.symbol != undefined ? params.symbol + '/' : '') + 'promotion/sum')
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* Retrieve the deposit address for a particular coin.
|
|
361
|
-
* @access public
|
|
362
|
-
* @param {{symbol: string}} params The coin's symbol to retrieve an address for.
|
|
363
|
-
* @return {Promise} An object containing the API response.
|
|
364
|
-
* @example
|
|
365
|
-
* kc.getDepositAddress({
|
|
366
|
-
* symbol: 'NEO'
|
|
367
|
-
* }).then(console.log).catch(console.error)
|
|
368
|
-
*
|
|
369
|
-
* // Returns:
|
|
370
|
-
*
|
|
371
|
-
* {
|
|
372
|
-
* "success": true,
|
|
373
|
-
* "code": "OK",
|
|
374
|
-
* "msg": "Operation succeeded.",
|
|
375
|
-
* "timestamp": 1509591494043,
|
|
376
|
-
* "data": {
|
|
377
|
-
* "oid": "xxxxxxxxxxxxxxxxxxxxxxxx",
|
|
378
|
-
* "address": "Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
|
379
|
-
* "context": null,
|
|
380
|
-
* "userOid": "xxxxxxxxxxxxxxxxxxxxxxxx",
|
|
381
|
-
* "coinType": "GAS",
|
|
382
|
-
* "createdAt": 1509354932000,
|
|
383
|
-
* "deletedAt": null,
|
|
384
|
-
* "updatedAt": 1509354932000,
|
|
385
|
-
* "lastReceivedAt": 1509541029000
|
|
386
|
-
* }
|
|
387
|
-
* }
|
|
388
|
-
*/
|
|
389
|
-
getDepositAddress(params = {}) {
|
|
390
|
-
return this.doSignedRequest('get', '/account/' + params.symbol + '/wallet/address')
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
/**
|
|
394
|
-
* Create a withdrawal request for the specified coin.
|
|
395
|
-
* @access public
|
|
396
|
-
* @param {{symbol: string, amount: number, address: string}} params Withdrawal details including the coin's symbol, amount, and address to withdraw to.
|
|
397
|
-
* @return {Promise} An object containing the API response.
|
|
398
|
-
* @example
|
|
399
|
-
* kc.createWithdrawal({
|
|
400
|
-
* symbol: 'NEO',
|
|
401
|
-
* amount: 5,
|
|
402
|
-
* address: 'AWcAwoXK6gbMUTojHMHEx8FgEfaVK9Hz5s'
|
|
403
|
-
* }).then(console.log).catch(console.error)
|
|
404
|
-
*/
|
|
405
|
-
createWithdrawal(params = {}) {
|
|
406
|
-
params.coin = params.symbol
|
|
407
|
-
return this.doSignedRequest('post', '/account/' + params.symbol + '/withdraw/apply', params)
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
/**
|
|
411
|
-
* Cancel a withdrawal request for the specified coin.
|
|
412
|
-
* @access public
|
|
413
|
-
* @param {{symbol: string, txOid: string}} params Withdrawal details including the coin's symbol and transaction ID for the withdrawal.
|
|
414
|
-
* @return {Promise} An object containing the API response.
|
|
415
|
-
* @example
|
|
416
|
-
* kc.cancelWithdrawal({
|
|
417
|
-
* symbol: 'NEO',
|
|
418
|
-
* txOid: '59fa71673b7468701cd714a1'
|
|
419
|
-
* }).then(console.log).catch(console.error)
|
|
420
|
-
*/
|
|
421
|
-
cancelWithdrawal(params = {}) {
|
|
422
|
-
return this.doSignedRequest('post', '/account/' + params.symbol + '/withdraw/cancel', params)
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
/**
|
|
426
|
-
* Retrieve deposit and withdrawal record history.
|
|
427
|
-
* @access public
|
|
428
|
-
* @param {{symbol: string, type: string, status: string, limit: number, page: number}} params Record details including the coin's symbol, type, status, limit, and page number for the records.
|
|
429
|
-
* @return {Promise} An object containing the API response.
|
|
430
|
-
* @example
|
|
431
|
-
* kc.getDepositAndWithdrawalRecords({
|
|
432
|
-
* symbol: 'GAS'
|
|
433
|
-
* }).then(console.log).catch(console.error)
|
|
434
|
-
*
|
|
435
|
-
* // Returns:
|
|
436
|
-
*
|
|
437
|
-
* {
|
|
438
|
-
* "success": true,
|
|
439
|
-
* "code": "OK",
|
|
440
|
-
* "msg": "Operation succeeded.",
|
|
441
|
-
* "timestamp": 1509591779228,
|
|
442
|
-
* "data": {
|
|
443
|
-
* "total": 2,
|
|
444
|
-
* "firstPage": true,
|
|
445
|
-
* "lastPage": false,
|
|
446
|
-
* "datas": [{
|
|
447
|
-
* "coinType": "GAS",
|
|
448
|
-
* "createdAt": 1509540909000,
|
|
449
|
-
* "amount": 0.1117,
|
|
450
|
-
* "address": "Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
|
451
|
-
* "fee": 0,
|
|
452
|
-
* "outerWalletTxid": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@gas",
|
|
453
|
-
* "remark": null,
|
|
454
|
-
* "oid": "xxxxxxxxxxxxxxxxxxxxxxxx",
|
|
455
|
-
* "confirmation": 7,
|
|
456
|
-
* "type": "DEPOSIT",
|
|
457
|
-
* "status": "SUCCESS",
|
|
458
|
-
* "updatedAt": 1509541029000
|
|
459
|
-
* }, {
|
|
460
|
-
* "coinType": "GAS",
|
|
461
|
-
* "createdAt": 1509358609000,
|
|
462
|
-
* "amount": 1.1249,
|
|
463
|
-
* "address": "Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
|
464
|
-
* "fee": 0,
|
|
465
|
-
* "outerWalletTxid": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@gas",
|
|
466
|
-
* "remark": null,
|
|
467
|
-
* "oid": "xxxxxxxxxxxxxxxxxxxxxxxx",
|
|
468
|
-
* "confirmation": 6,
|
|
469
|
-
* "type": "DEPOSIT",
|
|
470
|
-
* "status": "SUCCESS",
|
|
471
|
-
* "updatedAt": 1509358729000
|
|
472
|
-
* }],
|
|
473
|
-
* "currPageNo": 1,
|
|
474
|
-
* "limit": 12,
|
|
475
|
-
* "pageNos": 1
|
|
476
|
-
* }
|
|
477
|
-
* }
|
|
478
|
-
*/
|
|
479
|
-
getDepositAndWithdrawalRecords(params = {}) {
|
|
480
|
-
return this.doSignedRequest('get', '/account/' + params.symbol + '/wallet/records', params)
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
/**
|
|
484
|
-
* Retrieve balance for a particular coin.
|
|
485
|
-
* @access public
|
|
486
|
-
* @param {{symbol: string}} [params] The coin's symbol for the balance you want to retrieve.
|
|
487
|
-
* @return {Promise} An object containing the API response.
|
|
488
|
-
* @example <caption>Retrieve the balance for NEO:</caption>
|
|
489
|
-
* kc.getBalance({
|
|
490
|
-
* symbol: 'NEO'
|
|
491
|
-
* }).then(console.log).catch(console.error)
|
|
492
|
-
*
|
|
493
|
-
* // Returns:
|
|
494
|
-
*
|
|
495
|
-
* {
|
|
496
|
-
* "success": true,
|
|
497
|
-
* "code": "OK",
|
|
498
|
-
* "msg": "Operation succeeded.",
|
|
499
|
-
* "timestamp": 1509592077557,
|
|
500
|
-
* "data": {
|
|
501
|
-
* "coinType": "NEO",
|
|
502
|
-
* "balanceStr": "10.72040467",
|
|
503
|
-
* "freezeBalance": 0,
|
|
504
|
-
* "balance": 10.72040467,
|
|
505
|
-
* "freezeBalanceStr": "0.0"
|
|
506
|
-
* }
|
|
507
|
-
* }
|
|
508
|
-
* @example <caption>Retrieve the balance for all coins (including zero balances):</caption>
|
|
509
|
-
* kc.getBalance().then(console.log).catch(console.error)
|
|
510
|
-
*/
|
|
511
|
-
getBalance(params = {}) {
|
|
512
|
-
return this.doSignedRequest('get', '/account/' + (params.symbol ? params.symbol + '/' : '') + 'balance')
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
/**
|
|
516
|
-
* Create an order for the specified trading pair.
|
|
517
|
-
* @access public
|
|
518
|
-
* @param {{pair: string, amount: number, price: number, type: string}} params Order details including the trading pair, amount, price, and type of order.
|
|
519
|
-
* @return {Promise} An object containing the API response.
|
|
520
|
-
* @example <caption>Create an order to sell 5 GAS for NEO at the specified price:</caption>
|
|
521
|
-
* kc.createWithdrawal({
|
|
522
|
-
* pair: 'GAS-NEO',
|
|
523
|
-
* amount: 5,
|
|
524
|
-
* price: 0.608004
|
|
525
|
-
* type: 'SELL'
|
|
526
|
-
* }).then(console.log).catch(console.error)
|
|
527
|
-
*
|
|
528
|
-
* // Returns:
|
|
529
|
-
*
|
|
530
|
-
* {
|
|
531
|
-
* success: true,
|
|
532
|
-
* code: 'OK',
|
|
533
|
-
* msg: 'OK',
|
|
534
|
-
* timestamp: 1509592202904,
|
|
535
|
-
* data: {
|
|
536
|
-
* orderOid: 'xxxxxxxxxxxxxxxxxxxxxxxx'
|
|
537
|
-
* }
|
|
538
|
-
* }
|
|
539
|
-
*/
|
|
540
|
-
createOrder(params = {}) {
|
|
541
|
-
params.symbol = params.pair
|
|
542
|
-
return this.doSignedRequest('post', '/order', params)
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
/**
|
|
546
|
-
* View a list of active orders for the specified trading pair
|
|
547
|
-
* @access public
|
|
548
|
-
* @param {{pair: string}} params The trading pair to retrieve orders for.
|
|
549
|
-
* @return {Promise} An object containing the API response.
|
|
550
|
-
* @example
|
|
551
|
-
* kc.getActiveOrders({
|
|
552
|
-
* pair: 'GAS-NEO'
|
|
553
|
-
* }).then(console.log).catch(console.error)
|
|
554
|
-
*
|
|
555
|
-
* // Returns:
|
|
556
|
-
*
|
|
557
|
-
* {
|
|
558
|
-
* "success": true,
|
|
559
|
-
* "code": "OK",
|
|
560
|
-
* "msg": "Operation succeeded.",
|
|
561
|
-
* "timestamp": 1509592278263,
|
|
562
|
-
* "data": {
|
|
563
|
-
* "SELL": [[1509592203000, "SELL", 1, 0.11206064, 0, "xxxxxxxxxxxxxxxxxxxxxxxx"]],
|
|
564
|
-
* "BUY": []
|
|
565
|
-
* }
|
|
566
|
-
* }
|
|
567
|
-
*/
|
|
568
|
-
getActiveOrders(params = {}) {
|
|
569
|
-
params.symbol = params.pair
|
|
570
|
-
return this.doSignedRequest('get', '/' + params.pair + '/order/active', params)
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
/**
|
|
574
|
-
* Cancel an order for the specified trading pair.
|
|
575
|
-
* @access public
|
|
576
|
-
* @param {{pair: string, txOid: string}} params Order details including the trading pair and transaction ID for the order.
|
|
577
|
-
* @return {Promise} An object containing the API response.
|
|
578
|
-
* @example
|
|
579
|
-
* kc.cancelOrder({
|
|
580
|
-
* pair: 'GAS-NEO',
|
|
581
|
-
* txOid: '59fa71673b7468701cd714a1'
|
|
582
|
-
* }).then(console.log).catch(console.error)
|
|
583
|
-
*
|
|
584
|
-
* // Returns:
|
|
585
|
-
*
|
|
586
|
-
* {
|
|
587
|
-
* success: true,
|
|
588
|
-
* code: 'OK',
|
|
589
|
-
* msg: 'Operation succeeded.',
|
|
590
|
-
* timestamp: 1509592278426,
|
|
591
|
-
* data: null
|
|
592
|
-
* }
|
|
593
|
-
*/
|
|
594
|
-
cancelOrder(params = {}) {
|
|
595
|
-
params.symbol = params.pair
|
|
596
|
-
return this.doSignedRequest('post', '/cancel-order', params)
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
/**
|
|
600
|
-
* Retrieve a list of completed orders for the specified trading pair.
|
|
601
|
-
* @access public
|
|
602
|
-
* @param {{pair: string, type: string, limit: number, page: number}} params Order details including the trading pair, type, limit, and page number for the orders.
|
|
603
|
-
* @return {Promise} An object containing the API response.
|
|
604
|
-
* @example
|
|
605
|
-
* kc.getDealtOrders({
|
|
606
|
-
* pair: 'GAS-NEO'
|
|
607
|
-
* }).then(console.log).catch(console.error)
|
|
608
|
-
*
|
|
609
|
-
* // Returns:
|
|
610
|
-
*
|
|
611
|
-
* {
|
|
612
|
-
* "success": true,
|
|
613
|
-
* "code": "OK",
|
|
614
|
-
* "msg": "Operation succeeded.",
|
|
615
|
-
* "timestamp": 1509592427203,
|
|
616
|
-
* "data": {
|
|
617
|
-
* "total": 1,
|
|
618
|
-
* "firstPage": true,
|
|
619
|
-
* "lastPage": false,
|
|
620
|
-
* "datas": [{
|
|
621
|
-
* "coinType": "GAS",
|
|
622
|
-
* "createdAt": 1509455416000,
|
|
623
|
-
* "amount": 0.14494322,
|
|
624
|
-
* "dealValue": 0.0929086,
|
|
625
|
-
* "fee": 0.00009291,
|
|
626
|
-
* "dealDirection": "SELL",
|
|
627
|
-
* "coinTypePair": "NEO",
|
|
628
|
-
* "oid": "xxxxxxxxxxxxxxxxxxxxxxxx",
|
|
629
|
-
* "dealPrice": 0.641,
|
|
630
|
-
* "orderOid": "xxxxxxxxxxxxxxxxxxxxxxxx",
|
|
631
|
-
* "feeRate": 0.001,
|
|
632
|
-
* "direction": "SELL"
|
|
633
|
-
* }],
|
|
634
|
-
* "currPageNo": 1,
|
|
635
|
-
* "limit": 12,
|
|
636
|
-
* "pageNos": 1
|
|
637
|
-
* }
|
|
638
|
-
* }
|
|
639
|
-
*/
|
|
640
|
-
getDealtOrders(params = {}) {
|
|
641
|
-
params.symbol = params.pair
|
|
642
|
-
return this.doSignedRequest('get', '/' + params.pair + '/deal-orders', params)
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
/**
|
|
646
|
-
* Retrieve current price ticker data for the specified trading pair.
|
|
647
|
-
* @access public
|
|
648
|
-
* @param {{pair: string}} params The trading pair to retrieve price ticker for.
|
|
649
|
-
* @return {Promise} An object containing the API response.
|
|
650
|
-
* @example
|
|
651
|
-
* kc.getTicker({
|
|
652
|
-
* pair: 'GAS-NEO'
|
|
653
|
-
* }).then(console.log).catch(console.error)
|
|
654
|
-
*
|
|
655
|
-
* // Returns:
|
|
656
|
-
*
|
|
657
|
-
* {
|
|
658
|
-
* "success": true,
|
|
659
|
-
* "code": "OK",
|
|
660
|
-
* "msg": "Operation succeeded.",
|
|
661
|
-
* "timestamp": 1509592566746,
|
|
662
|
-
* "data": {
|
|
663
|
-
* "coinType": "GAS",
|
|
664
|
-
* "trading": true,
|
|
665
|
-
* "symbol": "GAS-NEO",
|
|
666
|
-
* "lastDealPrice": 0.627999,
|
|
667
|
-
* "buy": 0.608004,
|
|
668
|
-
* "sell": 0.628,
|
|
669
|
-
* "change": 0.019994,
|
|
670
|
-
* "coinTypePair": "NEO",
|
|
671
|
-
* "sort": 0,
|
|
672
|
-
* "feeRate": 0.001,
|
|
673
|
-
* "volValue": 5246.36133161,
|
|
674
|
-
* "high": 0.635,
|
|
675
|
-
* "datetime": 1509592566000,
|
|
676
|
-
* "vol": 8499.38951847,
|
|
677
|
-
* "low": 0.601101,
|
|
678
|
-
* "changeRate": 0.0329
|
|
679
|
-
* }
|
|
680
|
-
* }
|
|
681
|
-
*/
|
|
682
|
-
getTicker(params = {}) {
|
|
683
|
-
return this.doRequest('get', '/' + params.pair + '/open/tick')
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
/**
|
|
687
|
-
* Retrieve a list of orders for the specified trading pair.
|
|
688
|
-
* @access public
|
|
689
|
-
* @param {{pair: string, type: string, group: number, limit: number}} params Order book details including the trading pair, type, group, and limit for the orders.
|
|
690
|
-
* @return {Promise} An object containing the API response.
|
|
691
|
-
* @example <caption>Retrieve all orders currently on the books for the GAS-NEO trading pair:</caption>
|
|
692
|
-
* kc.getOrderBooks({
|
|
693
|
-
* pair: 'GAS-NEO'
|
|
694
|
-
* }).then(console.log).catch(console.error)
|
|
695
|
-
*
|
|
696
|
-
* // Returns:
|
|
697
|
-
*
|
|
698
|
-
* {
|
|
699
|
-
* "success": true,
|
|
700
|
-
* "code": "OK",
|
|
701
|
-
* "msg": "Operation succeeded.",
|
|
702
|
-
* "timestamp": 1509592645132,
|
|
703
|
-
* "data": {
|
|
704
|
-
* "SELL": [[0.628, 227.1374, 142.6422872], [0.632999, 10, 6.32999], [0.633, 4.20740806, 2.6632893], [0.65, 0.6346, 0.41249], [0.6611, 6.7998, 4.49534778], [0.665699, 0.1875, 0.12481856]],
|
|
705
|
-
* "BUY": [[0.608004, 9.8481, 5.98768419], [0.608003, 21.9264, 13.33131698], [0.608001, 43.8442, 26.65731744], [0.604001, 25.5521, 15.43349395], [0.603, 1.0561, 0.6368283], [0.602006, 25, 15.05015]]
|
|
706
|
-
* }
|
|
707
|
-
* }
|
|
708
|
-
* @example <caption>Retrieve only SELL orders currently on the books for the GAS-NEO trading pair:</caption>
|
|
709
|
-
* kc.getOrderBooks({
|
|
710
|
-
* pair: 'GAS-NEO',
|
|
711
|
-
* type: 'SELL'
|
|
712
|
-
* }).then(console.log).catch(console.error)
|
|
713
|
-
*
|
|
714
|
-
* // Returns:
|
|
715
|
-
*
|
|
716
|
-
* {
|
|
717
|
-
* "success": true,
|
|
718
|
-
* "code": "OK",
|
|
719
|
-
* "msg": "Operation succeeded.",
|
|
720
|
-
* "timestamp": 1509592734633,
|
|
721
|
-
* "data": [[0.628, 227.1374, 142.6422872], [0.632999, 10, 6.32999], [0.633, 4.20740806, 2.6632893], [0.65, 0.6346, 0.41249], [0.6611, 6.7998, 4.49534778], [0.665699, 0.1875, 0.12481856]]
|
|
722
|
-
* }
|
|
723
|
-
*/
|
|
724
|
-
getOrderBooks(params = {}) {
|
|
725
|
-
params.symbol = params.pair
|
|
726
|
-
return this.doRequest('get', '/' + params.pair + '/open/orders' + (params.type ? '-' + params.type.toLowerCase() : ''), params)
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
/**
|
|
730
|
-
* Retrieve a list of recently completed orders for the specified trading pair.
|
|
731
|
-
* @access public
|
|
732
|
-
* @param {{pair: string, limit: number, since: number}} params Order book details including the trading pair, limit, and since for the orders.
|
|
733
|
-
* @return {Promise} An object containing the API response.
|
|
734
|
-
* @example
|
|
735
|
-
* kc.getRecentlyDealtOrders({
|
|
736
|
-
* pair: 'GAS-NEO'
|
|
737
|
-
* }).then(console.log).catch(console.error)
|
|
738
|
-
*
|
|
739
|
-
* // Returns:
|
|
740
|
-
*
|
|
741
|
-
* {
|
|
742
|
-
* "success": true,
|
|
743
|
-
* "code": "OK",
|
|
744
|
-
* "msg": "Operation succeeded.",
|
|
745
|
-
* "timestamp": 1509592783348,
|
|
746
|
-
* "data": [[1509591191000, "SELL", 0.608005, 10.771, 6.54882186], [1509591198000, "SELL", 0.608005, 10.7648, 6.54505222], [1509591512000, "SELL", 0.608005, 13.0292, 7.92181875], [1509591714000, "BUY", 0.627999, 19.9774, 12.54578722], [1509591951000, "SELL", 0.608005, 15.6217, 9.49807171], [1509592026000, "SELL", 0.608005, 15.2009, 9.2422232], [1509592105000, "SELL", 0.608005, 13.4969, 8.20618268], [1509592219000, "BUY", 0.627999, 20.9506, 13.15695585], [1509592311000, "BUY", 0.627999, 23.5278, 14.77543487], [1509592724000, "SELL", 0.608005, 8.6837, 5.27973302]]
|
|
747
|
-
* }
|
|
748
|
-
*/
|
|
749
|
-
getRecentlyDealtOrders(params = {}) {
|
|
750
|
-
return this.doRequest('get', '/' + params.pair + '/open/deal-orders', params)
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
/**
|
|
754
|
-
* Retrieve a list of available trading pairs.
|
|
755
|
-
* @access public
|
|
756
|
-
* @return {Promise} An object containing the API response.
|
|
757
|
-
* @example
|
|
758
|
-
* kc.getTradingSymbols().then(console.log).catch(console.error)
|
|
759
|
-
*
|
|
760
|
-
* // Returns:
|
|
761
|
-
*
|
|
762
|
-
* {
|
|
763
|
-
* "success": true,
|
|
764
|
-
* "code": "OK",
|
|
765
|
-
* "msg": "Operation succeeded.",
|
|
766
|
-
* "timestamp": 1509592839027,
|
|
767
|
-
* "data": [{
|
|
768
|
-
* "coinType": "KCS",
|
|
769
|
-
* "trading": true,
|
|
770
|
-
* "symbol": "KCS-BTC",
|
|
771
|
-
* "lastDealPrice": 0.00009277,
|
|
772
|
-
* "buy": 0.00009003,
|
|
773
|
-
* "sell": 0.0000927,
|
|
774
|
-
* "change": -0.00000322,
|
|
775
|
-
* "coinTypePair": "BTC",
|
|
776
|
-
* "sort": 0,
|
|
777
|
-
* "feeRate": 0.001,
|
|
778
|
-
* "volValue": 139.78123495,
|
|
779
|
-
* "high": 0.00012281,
|
|
780
|
-
* "datetime": 1509592836000,
|
|
781
|
-
* "vol": 1347022.79127505,
|
|
782
|
-
* "low": 0.0000835,
|
|
783
|
-
* "changeRate": -0.0335
|
|
784
|
-
* }, {
|
|
785
|
-
* ...
|
|
786
|
-
* }]
|
|
787
|
-
* }
|
|
788
|
-
*/
|
|
789
|
-
getTradingSymbols() {
|
|
790
|
-
return this.doRequest('get', '/market/open/symbols')
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
/**
|
|
794
|
-
* Retrieve a list of trending trading pairs.
|
|
795
|
-
* @access public
|
|
796
|
-
* @return {Promise} An object containing the API response.
|
|
797
|
-
* @example
|
|
798
|
-
* kc.getTrending().then(console.log).catch(console.error)
|
|
799
|
-
*
|
|
800
|
-
* // Returns:
|
|
801
|
-
*
|
|
802
|
-
* {
|
|
803
|
-
* "success": true,
|
|
804
|
-
* "code": "OK",
|
|
805
|
-
* "msg": "Operation succeeded.",
|
|
806
|
-
* "timestamp": 1509593321973,
|
|
807
|
-
* "data": [{
|
|
808
|
-
* "coinPair": "KCS-BTC",
|
|
809
|
-
* "deals": [[1509591600000, 0.0000928], [1509588000000, 0.00009421], [1509584400000, 0.00009134], [1509580800000, 0.000096], [1509577200000, 0.00010014], [1509573600000, 0.00010293], [1509570000000, 0.00010368], [1509566400000, 0.000107], [1509562800000, 0.00010496], [1509559200000, 0.0001057], [1509555600000, 0.000108], [1509552000000, 0.0001117], [1509548400000, 0.0001142], [1509544800000, 0.000114], [1509541200000, 0.000114], [1509537600000, 0.0001135], [1509534000000, 0.0001135], [1509530400000, 0.0001011], [1509526800000, 0.00010799], [1509523200000, 0.00011405], [1509519600000, 0.0001164], [1509516000000, 0.00012099], [1509512400000, 0.00012107], [1509508800000, 0.00012244], [1509505200000, 0.00012281], [1509501600000, 0.00012295], [1509498000000, 0.00012348], [1509494400000, 0.0001242], [1509490800000, 0.00012895], [1509487200000, 0.00012897], [1509483600000, 0.00012899], [1509480000000, 0.00012849], [1509476400000, 0.00012987], [1509472800000, 0.00013], [1509469200000, 0.00013188], [1509465600000, 0.00012978], [1509462000000, 0.00012978], [1509458400000, 0.000126], [1509454800000, 0.00012978], [1509451200000, 0.00012562], [1509447600000, 0.00012999], [1509444000000, 0.00013009], [1509440400000, 0.0001346], [1509436800000, 0.00013465], [1509433200000, 0.00013465], [1509429600000, 0.00013376], [1509426000000, 0.00013465], [1509422400000, 0.00013457], [1509418800000, 0.00013489], [1509415200000, 0.00013693], [1509411600000, 0.0001329], [1509408000000, 0.00013499], [1509404400000, 0.00013711], [1509400800000, 0.00013723], [1509397200000, 0.00013999], [1509393600000, 0.00013992], [1509390000000, 0.00014195], [1509386400000, 0.00014284], [1509382800000, 0.0001425], [1509379200000, 0.00014286], [1509375600000, 0.00014406], [1509372000000, 0.00014591], [1509368400000, 0.00014647], [1509364800000, 0.0001457], [1509361200000, 0.00014575], [1509357600000, 0.00014659], [1509354000000, 0.00014998], [1509350400000, 0.0001517], [1509346800000, 0.0001488], [1509343200000, 0.0001488], [1509339600000, 0.00014999], [1509336000000, 0.0001521]]
|
|
810
|
-
* }, {
|
|
811
|
-
* ...
|
|
812
|
-
* }]
|
|
813
|
-
* }
|
|
814
|
-
*/
|
|
815
|
-
getTrending() {
|
|
816
|
-
return this.doRequest('get', '/market/open/coins-trending')
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
/**
|
|
820
|
-
* Retrieve a list of available coins.
|
|
821
|
-
* @access public
|
|
822
|
-
* @return {Promise} An object containing the API response.
|
|
823
|
-
* @example
|
|
824
|
-
* kc.getCoins().then(console.log).catch(console.error)
|
|
825
|
-
*
|
|
826
|
-
* // Returns:
|
|
827
|
-
*
|
|
828
|
-
* {
|
|
829
|
-
* "success": true,
|
|
830
|
-
* "code": "OK",
|
|
831
|
-
* "msg": "Operation succeeded.",
|
|
832
|
-
* "timestamp": 1509593539250,
|
|
833
|
-
* "data": [{
|
|
834
|
-
* "withdrawMinFee": 2,
|
|
835
|
-
* "withdrawMinAmount": 50,
|
|
836
|
-
* "withdrawFeeRate": 0.001,
|
|
837
|
-
* "confirmationCount": 12,
|
|
838
|
-
* "name": "Kucoin Shares",
|
|
839
|
-
* "tradePrecision": 4,
|
|
840
|
-
* "enableWithdraw": true,
|
|
841
|
-
* "enableDeposit": true,
|
|
842
|
-
* "coin": "KCS"
|
|
843
|
-
* }, {
|
|
844
|
-
* ...
|
|
845
|
-
* }]
|
|
846
|
-
* }
|
|
847
|
-
*/
|
|
848
|
-
getCoins() {
|
|
849
|
-
return this.doRequest('get', '/market/open/coins-list')
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
module.exports = Kucoin
|