KuCoin API Client
A Node.js client for the [KuCoin](https://www.kucoin.com/) API.
Overview
What does it currently do
The KuCoin API documentation is not too bad, though some holes and inconsistencies. This Node.js client attempts to make up for some of those. 25 of the 29 endpoints are supported, the missing ones are mainly relating to Kline data.
Get help or give help
- Open a new issue if you encounter a problem.
- Or ping @satoshinaire on Twitter.
- Pull requests welcome.
Getting started
Installation
npm install --save kucoin-api
Usage
'use strict'
require('dotenv').config()
const Kucoin = require('kucoin-api')
let kc = new Kucoin(process.env.KUCOIN_API_KEY, process.env.KUCOIN_API_SECRET)
kc.getBalance({
symbol: 'GAS'
})
.then((result) => {
console.log(result)
})
.catch((err) => {
console.log(err)
})
API
Kucoin
A Node.js client for the KuCoin API.
Parameters
Examples
let kc = ;
Meta
- version: 0.0.2
getExchangeRates
Retrieve exchange rates for coins.
Parameters
params
{symbols: Array<string>}? An Array of symbols, or if blank BTC will be returned. (optional, default{}
)
Examples
Specify one or more symbols:
kc // Returns: "success": true "code": "OK" "msg": "Operation succeeded." "timestamp": 1509589905631 "data": "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" "rates": "GAS": "CHF": 1457 "HRK": 9419 "MXN": 27902 "ZAR": 20531 "INR": 93959 "CNY": 9615 "THB": 4823 "AUD": 1895 "ILS": 5116 "KRW": 1617681 "JPY": 166088 "PLN": 5303 "GBP": 1094 "IDR": 19757769 "HUF": 390486 "PHP": 75163 "TRY": 556 "RUB": 84561 "HKD": 11347 "EUR": 1252 "DKK": 9321 "USD": 1454 "CAD": 1877 "MYR": 6154 "BGN": 2449 "NOK": 1185 "RON": 5766 "SGD": 198 "CZK": 32011 "SEK": 12216 "NZD": 2112 "BRL": 4778 "NEO": "CHF": 2533 "HRK": 16366 "MXN": 48481 "ZAR": 35673 "INR": 163255 "CNY": 16707 "THB": 83801 "AUD": 3294 "ILS": 8889 "KRW": 2810731 "JPY": 288578 "PLN": 9214 "GBP": 1901 "IDR": 3432924 "HUF": 678472 "PHP": 130597 "TRY": 9661 "RUB": 146925 "HKD": 19716 "EUR": 2176 "DKK": 16195 "USD": 2527 "CAD": 3261 "MYR": 10693 "BGN": 4256 "NOK": 2059 "RON": 10018 "SGD": 344 "CZK": 5562 "SEK": 21227 "NZD": 367 "BRL": 8302
Retrieve data for BTC by default:
kc // Returns: "success": true "code": "OK" "msg": "Operation succeeded." "timestamp": 1509590207497 "data": "rates": "BTC": "CHF": 681762 "HRK": 4404589 "MXN": 13047613 "ZAR": 9600715 "INR": 43936398 "CNY": 4496339 "THB": 2255311 "AUD": 886549 "ILS": 2392357 "KRW": 756440586 "JPY": 77664044 "PLN": 2479821 "GBP": 511825 "IDR": 923888592 "HUF": 182594501 "PHP": 35147078 "TRY": 2600205 "RUB": 39541397 "HKD": 530617 "EUR": 585714 "DKK": 4358613 "USD": 68013 "CAD": 877775 "MYR": 287797 "BGN": 1145542 "NOK": 5541427 "RON": 2696239 "SGD": 925928 "CZK": 14968981 "SEK": 5712751 "NZD": 987888 "BRL": 2234499 "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"
Returns Promise An object containing the API response.
getLanguages
Retrieve a list of supported languages.
Examples
kc // Returns: "success": true "code": "OK" "msg": "Operation succeeded." "timestamp": 1509590811348 "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
Returns Promise An object containing the API response.
changeLanguage
Change the language for your account.
Parameters
params
{lang: string} The specific language locale to change to from the list provided by getLanguages. (optional, default{}
)
Examples
kc // Returns: "success": true "code": "OK" "msg": "Operation succeeded." "timestamp": 1509590866149 "data": null
Returns Promise An object containing the API response.
getUserInfo
Get account information for the authenticated user.
Examples
kc // Returns: "success": true "code": "OK" "msg": "Operation succeeded." "timestamp": 1509590943414 "data": "referrer_code": "XXXXXX" "photoCredentialValidated": false "videoValidated": false "language": "en_US" "csrf": "XXXXXXXXXXXXXXXXXXXXXXX=" "oid": "xxxxxxxxxxxxxxxxxxxxxxxx" "baseFeeRate": 1 "hasCredential": false "phoneValidated": true "phone": "" "credentialValidated": false "googleTwoFaBinding": true "nickname": null "name": "" "hasTradePassword": false "currency": null "emailValidated": true "email": "hello@example.com"
Returns Promise An object containing the API response.
getInviteCount
Get the number of invitees from the authenticated user's referral code.
Examples
kc // Returns: "success": true "code": "OK" "msg": "Operation succeeded." "timestamp": 1509591130780 "data": "countThree": 0 "count": 0 "countTwo": 0
Returns Promise An object containing the API response.
getPromotionRewardInfo
Get promotion reward info.
Parameters
params
{symbol: string}? The coin's symbol to retrieve reward info for. (optional, default{}
)
Examples
Specify a symbol:
kc
Retrieve data for all symbols:
kc // Returns: "success": true "code": "OK" "msg": "Operation succeeded." "timestamp": 1509591205512 "data": "grantCountDownSeconds": 219994 "drawingCount": 0 "assignedCount": 0
Returns Promise An object containing the API response.
getPromotionRewardSummary
Get promotion reward summary.
Parameters
params
{symbol: string}? The coin's symbol to retrieve reward summary for. (optional, default{}
)
Examples
Specify a symbol:
kc
Retrieve data for all symbols:
kc // Returns: "success": true "code": "OK" "msg": "Operation succeeded." "timestamp": 1509591324280 "data":
Returns Promise An object containing the API response.
getDepositAddress
Retrieve the deposit address for a particular coin.
Parameters
params
{symbol: string} The coin's symbol to retrieve an address for. (optional, default{}
)
Examples
kc // Returns: "success": true "code": "OK" "msg": "Operation succeeded." "timestamp": 1509591494043 "data": "oid": "xxxxxxxxxxxxxxxxxxxxxxxx" "address": "Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "context": null "userOid": "xxxxxxxxxxxxxxxxxxxxxxxx" "coinType": "GAS" "createdAt": 1509354932000 "deletedAt": null "updatedAt": 1509354932000 "lastReceivedAt": 1509541029000
Returns Promise An object containing the API response.
createWithdrawal
Create a withdrawal request for the specified coin.
Parameters
params
{symbol: string, amount: number, address: string} Withdrawal details including the coin's symbol, amount, and address to withdraw to. (optional, default{}
)
Examples
kc
Returns Promise An object containing the API response.
cancelWithdrawal
Cancel a withdrawal request for the specified coin.
Parameters
params
{symbol: string, txOid: string} Withdrawal details including the coin's symbol and transaction ID for the withdrawal. (optional, default{}
)
Examples
kc
Returns Promise An object containing the API response.
getDepositAndWithdrawalRecords
Retrieve deposit and withdrawal record history.
Parameters
params
{symbol: string, type: string, status: string, limit: number, page: number} Record details including the coin's symbol, type, status, limit, and page number for the records. (optional, default{}
)
Examples
kc // Returns: "success": true "code": "OK" "msg": "Operation succeeded." "timestamp": 1509591779228 "data": "total": 2 "firstPage": true "lastPage": false "datas": "coinType": "GAS" "createdAt": 1509540909000 "amount": 01117 "address": "Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "fee": 0 "outerWalletTxid": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@gas" "remark": null "oid": "xxxxxxxxxxxxxxxxxxxxxxxx" "confirmation": 7 "type": "DEPOSIT" "status": "SUCCESS" "updatedAt": 1509541029000 "coinType": "GAS" "createdAt": 1509358609000 "amount": 11249 "address": "Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "fee": 0 "outerWalletTxid": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@gas" "remark": null "oid": "xxxxxxxxxxxxxxxxxxxxxxxx" "confirmation": 6 "type": "DEPOSIT" "status": "SUCCESS" "updatedAt": 1509358729000 "currPageNo": 1 "limit": 12 "pageNos": 1
Returns Promise An object containing the API response.
getBalance
Retrieve balance for a particular coin.
Parameters
params
{symbol: string}? The coin's symbol for the balance you want to retrieve. (optional, default{}
)
Examples
Retrieve the balance for NEO:
kc // Returns: "success": true "code": "OK" "msg": "Operation succeeded." "timestamp": 1509592077557 "data": "coinType": "NEO" "balanceStr": "10.72040467" "freezeBalance": 0 "balance": 1072040467 "freezeBalanceStr": "0.0"
Retrieve the balance for all coins (including zero balances):
kc
Returns Promise An object containing the API response.
createOrder
Create an order for the specified trading pair.
Parameters
params
{pair: string, amount: number, price: number, type: string} Order details including the trading pair, amount, price, and type of order. (optional, default{}
)
Examples
Create an order to sell 5 GAS for NEO at the specified price:
kc // Returns: success: true code: 'OK' msg: 'OK' timestamp: 1509592202904 data: orderOid: 'xxxxxxxxxxxxxxxxxxxxxxxx'
Returns Promise An object containing the API response.
getActiveOrders
View a list of active orders for the specified trading pair
Parameters
params
{pair: string} The trading pair to retrieve orders for. (optional, default{}
)
Examples
kc // Returns: "success": true "code": "OK" "msg": "Operation succeeded." "timestamp": 1509592278263 "data": "SELL": 1509592203000 "SELL" 1 011206064 0 "xxxxxxxxxxxxxxxxxxxxxxxx" "BUY":
Returns Promise An object containing the API response.
cancelOrder
Cancel an order for the specified trading pair.
Parameters
params
{pair: string, txOid: string} Order details including the trading pair and transaction ID for the order. (optional, default{}
)
Examples
kc // Returns: success: true code: 'OK' msg: 'Operation succeeded.' timestamp: 1509592278426 data: null
Returns Promise An object containing the API response.
getDealtOrders
Retrieve a list of completed orders for the specified trading pair.
Parameters
params
{pair: string, type: string, limit: number, page: number} Order details including the trading pair, type, limit, and page number for the orders. (optional, default{}
)
Examples
kc // Returns: "success": true "code": "OK" "msg": "Operation succeeded." "timestamp": 1509592427203 "data": "total": 1 "firstPage": true "lastPage": false "datas": "coinType": "GAS" "createdAt": 1509455416000 "amount": 014494322 "dealValue": 00929086 "fee": 000009291 "dealDirection": "SELL" "coinTypePair": "NEO" "oid": "xxxxxxxxxxxxxxxxxxxxxxxx" "dealPrice": 0641 "orderOid": "xxxxxxxxxxxxxxxxxxxxxxxx" "feeRate": 0001 "direction": "SELL" "currPageNo": 1 "limit": 12 "pageNos": 1
Returns Promise An object containing the API response.
getTicker
Retrieve current price ticker data for the specified trading pair.
Parameters
params
{pair: string} The trading pair to retrieve price ticker for. (optional, default{}
)
Examples
kc // Returns: "success": true "code": "OK" "msg": "Operation succeeded." "timestamp": 1509592566746 "data": "coinType": "GAS" "trading": true "symbol": "GAS-NEO" "lastDealPrice": 0627999 "buy": 0608004 "sell": 0628 "change": 0019994 "coinTypePair": "NEO" "sort": 0 "feeRate": 0001 "volValue": 524636133161 "high": 0635 "datetime": 1509592566000 "vol": 849938951847 "low": 0601101 "changeRate": 00329
Returns Promise An object containing the API response.
getOrderBooks
Retrieve a list of orders for the specified trading pair.
Parameters
params
{pair: string, type: string, group: number, limit: number} Order book details including the trading pair, type, group, and limit for the orders. (optional, default{}
)
Examples
Retrieve all orders currently on the books for the GAS-NEO trading pair:
kc // Returns: "success": true "code": "OK" "msg": "Operation succeeded." "timestamp": 1509592645132 "data": "SELL": 0628 2271374 1426422872 0632999 10 632999 0633 420740806 26632893 065 06346 041249 06611 67998 449534778 0665699 01875 012481856 "BUY": 0608004 98481 598768419 0608003 219264 1333131698 0608001 438442 2665731744 0604001 255521 1543349395 0603 10561 06368283 0602006 25 1505015
Retrieve only SELL orders currently on the books for the GAS-NEO trading pair:
kc // Returns: "success": true "code": "OK" "msg": "Operation succeeded." "timestamp": 1509592734633 "data": 0628 2271374 1426422872 0632999 10 632999 0633 420740806 26632893 065 06346 041249 06611 67998 449534778 0665699 01875 012481856
Returns Promise An object containing the API response.
getRecentlyDealtOrders
Retrieve a list of recently completed orders for the specified trading pair.
Parameters
params
{pair: string, limit: number, since: number} Order book details including the trading pair, limit, and since for the orders. (optional, default{}
)
Examples
kc // Returns: "success": true "code": "OK" "msg": "Operation succeeded." "timestamp": 1509592783348 "data": 1509591191000 "SELL" 0608005 10771 654882186 1509591198000 "SELL" 0608005 107648 654505222 1509591512000 "SELL" 0608005 130292 792181875 1509591714000 "BUY" 0627999 199774 1254578722 1509591951000 "SELL" 0608005 156217 949807171 1509592026000 "SELL" 0608005 152009 92422232 1509592105000 "SELL" 0608005 134969 820618268 1509592219000 "BUY" 0627999 209506 1315695585 1509592311000 "BUY" 0627999 235278 1477543487 1509592724000 "SELL" 0608005 86837 527973302
Returns Promise An object containing the API response.
getTradingSymbols
Retrieve a list of available trading pairs.
Examples
kc // Returns: "success": true "code": "OK" "msg": "Operation succeeded." "timestamp": 1509592839027 "data": "coinType": "KCS" "trading": true "symbol": "KCS-BTC" "lastDealPrice": 000009277 "buy": 000009003 "sell": 00000927 "change": -000000322 "coinTypePair": "BTC" "sort": 0 "feeRate": 0001 "volValue": 13978123495 "high": 000012281 "datetime": 1509592836000 "vol": 134702279127505 "low": 00000835 "changeRate": -00335 ...
Returns Promise An object containing the API response.
getTrending
Retrieve a list of trending trading pairs.
Examples
kc // Returns: "success": true "code": "OK" "msg": "Operation succeeded." "timestamp": 1509593321973 "data": "coinPair": "KCS-BTC" "deals": 1509591600000 00000928 1509588000000 000009421 1509584400000 000009134 1509580800000 0000096 1509577200000 000010014 1509573600000 000010293 1509570000000 000010368 1509566400000 0000107 1509562800000 000010496 1509559200000 00001057 1509555600000 0000108 1509552000000 00001117 1509548400000 00001142 1509544800000 0000114 1509541200000 0000114 1509537600000 00001135 1509534000000 00001135 1509530400000 00001011 1509526800000 000010799 1509523200000 000011405 1509519600000 00001164 1509516000000 000012099 1509512400000 000012107 1509508800000 000012244 1509505200000 000012281 1509501600000 000012295 1509498000000 000012348 1509494400000 00001242 1509490800000 000012895 1509487200000 000012897 1509483600000 000012899 1509480000000 000012849 1509476400000 000012987 1509472800000 000013 1509469200000 000013188 1509465600000 000012978 1509462000000 000012978 1509458400000 0000126 1509454800000 000012978 1509451200000 000012562 1509447600000 000012999 1509444000000 000013009 1509440400000 00001346 1509436800000 000013465 1509433200000 000013465 1509429600000 000013376 1509426000000 000013465 1509422400000 000013457 1509418800000 000013489 1509415200000 000013693 1509411600000 00001329 1509408000000 000013499 1509404400000 000013711 1509400800000 000013723 1509397200000 000013999 1509393600000 000013992 1509390000000 000014195 1509386400000 000014284 1509382800000 00001425 1509379200000 000014286 1509375600000 000014406 1509372000000 000014591 1509368400000 000014647 1509364800000 00001457 1509361200000 000014575 1509357600000 000014659 1509354000000 000014998 1509350400000 00001517 1509346800000 00001488 1509343200000 00001488 1509339600000 000014999 1509336000000 00001521 ...
Returns Promise An object containing the API response.
getCoins
Retrieve a list of available coins.
Examples
kc // Returns: "success": true "code": "OK" "msg": "Operation succeeded." "timestamp": 1509593539250 "data": "withdrawMinFee": 2 "withdrawMinAmount": 50 "withdrawFeeRate": 0001 "confirmationCount": 12 "name": "Kucoin Shares" "tradePrecision": 4 "enableWithdraw": true "enableDeposit": true "coin": "KCS" ...
Returns Promise An object containing the API response.
License
- Open-source MIT.
- Main author is @satoshinaire.
Donations
NEO / GAS accepted at AWcAwoXK6gbMUTojHMHEx8FgEfaVK9Hz5s