Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

kucoin-node-sdk

Kucoin2.1kApache-2.01.1.1

KuCoin API SDK for Node.js language

readme

kucoin-node-sdk for KuCoin API

KuCoin API SDK for Node.js language

The detailed document https://docs.kucoin.com.

Latest Version

Env

Nodejs version >= 10.0

Install

# install by npm
npm install kucoin-node-sdk


# install by yarn
yarn add kucoin-node-sdk

Init Configure

module.exports = {
  baseUrl: '',
  apiAuth: {
    key: '', // KC-API-KEY
    secret: '', // API-Secret
    passphrase: '', // KC-API-PASSPHRASE
  },
  authVersion: 2, // KC-API-KEY-VERSION. Notice: for v2 API-KEY, not required for v1 version.
};

You can use baseUrl method to change evironment. | Environment | BaseUri | | -------- | -------- | | Production DEFAULT | https://openapi-v2.kucoin.com | | Sandbox | https://openapi-sandbox.kucoin.com |

If you only need to use the public web socket client or REST client public method, you can igonre withApiKey method. To customize your own API implementation, you may use the with*API method we provided for you.

Usage

/** Require SDK */
const API = require('kucoin-node-sdk');

/** Init Configure */
API.init(require('./config'));

/** API use */
const main = async () => {
  const getTimestampRl = await API.rest.Others.getTimestamp();
  console.log(getTimestampRl.data);
};

/** Run Demo for all apis */
REST API: yarn dev
SW:  yarn dev-ws (you can opt the params for different sw demo in demo,such as follow exp)

"dev-ws": "cross-env PRODUCTION=dev nodemon demo/xxx_demo.js",

Demo SDK for all APIS

DEMO: demo/index.js

API Modules

Rest/User

Signature is required for this part.

Rest/User/UserInfo

  • <input checked="" disabled="" type="checkbox"> getSubUsers
  • <input checked="" disabled="" type="checkbox"> getPaginatedSubUsers

    Rest/User/Account

  • <input checked="" disabled="" type="checkbox"> createAccount
  • <input checked="" disabled="" type="checkbox"> getAccountsList
  • <input checked="" disabled="" type="checkbox"> getAccountInformation
  • <input checked="" disabled="" type="checkbox"> getAccountLedgers
  • <input checked="" disabled="" type="checkbox"> getHolds
  • <input checked="" disabled="" type="checkbox"> getBalanceOfSubAccount
  • <input checked="" disabled="" type="checkbox"> getAggregatedBalanceOfAllSubAccounts
  • <input checked="" disabled="" type="checkbox"> getTransferable
  • <input checked="" disabled="" type="checkbox"> transferBetweenMasterUserAndSubUser
  • <input checked="" disabled="" type="checkbox"> innerTransfer
  • <input checked="" disabled="" type="checkbox"> getAccountSummaryInfo
  • <input checked="" disabled="" type="checkbox"> createSubAccount
  • <input checked="" disabled="" type="checkbox"> getSubAccountSpotApiList
  • <input checked="" disabled="" type="checkbox"> createSpotAPIsForSubAccount
  • <input checked="" disabled="" type="checkbox"> updateSubAccountSpotApis
  • <input checked="" disabled="" type="checkbox"> deleteSubAccountSpotApis
  • <input checked="" disabled="" type="checkbox"> getPaginatedSubAccountInformation
  • <input checked="" disabled="" type="checkbox"> transferToHFAccount
  • <input checked="" disabled="" type="checkbox"> getHighFrequencyAccountLedger
  • <input checked="" disabled="" type="checkbox"> getUserType

Rest/User/Deposit

  • <input checked="" disabled="" type="checkbox"> createDepositAddress
  • <input checked="" disabled="" type="checkbox"> getDepositAddressV2
  • <input checked="" disabled="" type="checkbox"> getDepositAddress
  • <input checked="" disabled="" type="checkbox"> getDepositList
  • <input checked="" disabled="" type="checkbox"> getV1HistoricalDepositsList

    Rest/User/Withdrawals

  • <input checked="" disabled="" type="checkbox"> getWithdrawalsList
  • <input checked="" disabled="" type="checkbox"> getV1HistoricalWithdrawalsList
  • <input checked="" disabled="" type="checkbox"> getWithdrawalQuotas
  • <input checked="" disabled="" type="checkbox"> applyWithdraw
  • <input checked="" disabled="" type="checkbox"> cancelWithdrawal

    Rest/User/TradeFee

  • <input checked="" disabled="" type="checkbox"> getBasicUserFee
  • <input checked="" disabled="" type="checkbox"> getActualFeeRateBySymbols

Rest/Trade

Signature is required for this part.

Rest/Trade/Orders

  • <input checked="" disabled="" type="checkbox"> postOrder
  • <input checked="" disabled="" type="checkbox"> postMultiOrders
  • <input checked="" disabled="" type="checkbox"> cancelOrder
  • <input checked="" disabled="" type="checkbox"> cancelOrderByClientOid
  • <input checked="" disabled="" type="checkbox"> cancelAllOrders
  • <input checked="" disabled="" type="checkbox"> getOrdersList
  • <input checked="" disabled="" type="checkbox"> getV1HistoricalOrdersList
  • <input checked="" disabled="" type="checkbox"> getRecentOrders
  • <input checked="" disabled="" type="checkbox"> getOrderByID
  • <input checked="" disabled="" type="checkbox"> getSingleActiveOrderByClientOid
  • <input checked="" disabled="" type="checkbox"> placeHfOrder
  • <input checked="" disabled="" type="checkbox"> syncPlaceHfOrder
  • <input checked="" disabled="" type="checkbox"> placeMultipleHfOrders
  • <input checked="" disabled="" type="checkbox"> syncPlaceMultipleHfOrders
  • <input checked="" disabled="" type="checkbox"> modifyOrder
  • <input checked="" disabled="" type="checkbox"> cancelOrdersByOrderId
  • <input checked="" disabled="" type="checkbox"> syncCancelOrdersByOrderId
  • <input checked="" disabled="" type="checkbox"> cancelOrderByClientOid
  • <input checked="" disabled="" type="checkbox"> syncCancelOrdersByClientOid
  • <input checked="" disabled="" type="checkbox"> cancelSpecifiedNumberOfOrdersByOrderId
  • <input checked="" disabled="" type="checkbox"> cancelAllHfOrdersBySymbol
  • <input checked="" disabled="" type="checkbox"> obtainListOfActiveHfOrders
  • <input checked="" disabled="" type="checkbox"> obtainListOfSymbolWithActiveHfOrders
  • <input checked="" disabled="" type="checkbox"> obtainListOfFilledHfOrders
  • <input checked="" disabled="" type="checkbox"> detailsOfAsingleHfOrder
  • <input checked="" disabled="" type="checkbox"> obtainDetailsOfASingleHfOrder
  • <input checked="" disabled="" type="checkbox"> hfAutoCancelSetting
  • <input checked="" disabled="" type="checkbox"> queryHfAutoCancelOrderSetting
  • <input checked="" disabled="" type="checkbox"> cancelAllHfOrders

    Rest/Trade/StopOrder

  • <input checked="" disabled="" type="checkbox"> postStopOrder
  • <input checked="" disabled="" type="checkbox"> cancelOrder
  • <input checked="" disabled="" type="checkbox"> cancelMultiOrders
  • <input checked="" disabled="" type="checkbox"> getOrder
  • <input checked="" disabled="" type="checkbox"> getStopOrderList
  • <input checked="" disabled="" type="checkbox"> getOrderByClientOid
  • <input checked="" disabled="" type="checkbox"> cancelSingleOrderByClientOid
  • <input checked="" disabled="" type="checkbox"> getSingleStopOrderInfo
  • <input checked="" disabled="" type="checkbox"> cancelStopOrder

    Rest/Trade/Fills

  • <input checked="" disabled="" type="checkbox"> getFillsList
  • <input checked="" disabled="" type="checkbox"> getRecentFills
  • <input checked="" disabled="" type="checkbox"> getHfTransactionRecords

    Rest/Trade/OCOOrder

  • <input checked="" disabled="" type="checkbox"> placeOrder
  • <input checked="" disabled="" type="checkbox"> cancelOrder
  • <input checked="" disabled="" type="checkbox"> cancelAllOrders
  • <input checked="" disabled="" type="checkbox"> getOrders
  • <input checked="" disabled="" type="checkbox"> getOrderDetails
  • <input checked="" disabled="" type="checkbox"> getOrderByClientOid

Rest/Market

Signature is not required for this part

Rest/Market/Symbols

  • <input checked="" disabled="" type="checkbox"> getSymbolsList
  • <input checked="" disabled="" type="checkbox"> getTicker
  • <input checked="" disabled="" type="checkbox"> getAllTickers
  • <input checked="" disabled="" type="checkbox"> get24hrStats
  • <input checked="" disabled="" type="checkbox"> getMarketList
  • <input checked="" disabled="" type="checkbox"> getSymbolDetail

Rest/Market/OrderBook

  • <input checked="" disabled="" type="checkbox"> getLevel2_20
  • <input checked="" disabled="" type="checkbox"> getLevel2_100
  • <input checked="" disabled="" type="checkbox"> getLevel2_full
  • <input checked="" disabled="" type="checkbox"> getLevel3_full

    Rest/Market/Histories

  • <input checked="" disabled="" type="checkbox"> getMarketHistories
  • <input checked="" disabled="" type="checkbox"> getMarketCandles

    Rest/Market/Currencies

  • <input checked="" disabled="" type="checkbox"> getCurrencies
  • <input checked="" disabled="" type="checkbox"> getCurrencyDetail
  • <input checked="" disabled="" type="checkbox"> getFiatPrice
  • <input checked="" disabled="" type="checkbox"> getCurrencyDetail_V3

    Rest/Margin/MarginInfo

  • <input checked="" disabled="" type="checkbox"> getMarkPrice
  • <input checked="" disabled="" type="checkbox"> getMarginConfigurationInfo
  • <input checked="" disabled="" type="checkbox"> getMarginAccount
  • <input checked="" disabled="" type="checkbox"> postMarginOrder
  • <input checked="" disabled="" type="checkbox"> getMarginPriceStrategy
  • <input checked="" disabled="" type="checkbox"> getMarginCurrencies
  • <input checked="" disabled="" type="checkbox"> getEtfInfo

    Rest/Margin/BorrowAndLend

  • <input checked="" disabled="" type="checkbox"> postBorrowOrder
  • <input checked="" disabled="" type="checkbox"> getBorrowOrder
  • <input checked="" disabled="" type="checkbox"> getRepayRecord
  • <input checked="" disabled="" type="checkbox"> getRepaymentRecord
  • <input checked="" disabled="" type="checkbox"> repayAll
  • <input checked="" disabled="" type="checkbox"> repaySingle
  • <input checked="" disabled="" type="checkbox"> postLendOrder
  • <input checked="" disabled="" type="checkbox"> cancelLendOrder
  • <input checked="" disabled="" type="checkbox"> setAutoLend
  • <input checked="" disabled="" type="checkbox"> getActiveOrder
  • <input checked="" disabled="" type="checkbox"> getLentHistory
  • <input checked="" disabled="" type="checkbox"> getActiveLendOrdersList
  • <input checked="" disabled="" type="checkbox"> getSettledLendOrderHistory
  • <input checked="" disabled="" type="checkbox"> getAccountLendRecord
  • <input checked="" disabled="" type="checkbox"> getLendingMarketData
  • <input checked="" disabled="" type="checkbox"> getMarginFillsTradeData

    Rest/Margin/Isolated

  • <input checked="" disabled="" type="checkbox"> queryIsolatedMarginTradingPairConfiguration
  • <input checked="" disabled="" type="checkbox"> queryIsolatedMarginAccountInfo
  • <input checked="" disabled="" type="checkbox"> querySingleIsolatedMarginAccountInfo
  • <input checked="" disabled="" type="checkbox"> isolatedMarginBorrowing
  • <input checked="" disabled="" type="checkbox"> queryOutstandingRepaymentRecords
  • <input checked="" disabled="" type="checkbox"> queryRepaymentRecords
  • <input checked="" disabled="" type="checkbox"> quickRepayment
  • <input checked="" disabled="" type="checkbox"> singleRepayment

    Rest/Margin/MarginV3

  • <input checked="" disabled="" type="checkbox"> marginBorrowV3
  • <input checked="" disabled="" type="checkbox"> getBorrowHistoryV3
  • <input checked="" disabled="" type="checkbox"> repayMarginLoanV3
  • <input checked="" disabled="" type="checkbox"> getRepayHistoryV3
  • <input checked="" disabled="" type="checkbox"> getMarginInterestRecordsV3
  • <input checked="" disabled="" type="checkbox"> getLendingCurrencyInfoV3
  • <input checked="" disabled="" type="checkbox"> getMarketInterestRateV3
  • <input checked="" disabled="" type="checkbox"> initiatePurchaseV3
  • <input checked="" disabled="" type="checkbox"> getPurchaseOrdersV3
  • <input checked="" disabled="" type="checkbox"> redeemMarketV3
  • <input checked="" disabled="" type="checkbox"> getRedemptionOrdersV3
  • updatePurchaseOrderInterestRateV3

  • getCrossMarginTradingPairs

  • <input checked="" disabled="" type="checkbox"> updateLeverageMultiplier
  • <input checked="" disabled="" type="checkbox"> placeHfMarginOrder
  • <input checked="" disabled="" type="checkbox"> testHfMarginOrder
  • <input checked="" disabled="" type="checkbox"> cancelHfMarginOrder
  • <input checked="" disabled="" type="checkbox"> cancelHfMarginOrderByClientOid
  • <input checked="" disabled="" type="checkbox"> cancelAllHfMarginOrdersBySymbol
  • <input checked="" disabled="" type="checkbox"> getActiveHfMarginOrders
  • <input checked="" disabled="" type="checkbox"> getFilledHfMarginOrders
  • <input checked="" disabled="" type="checkbox"> getHfOrderDetails
  • <input checked="" disabled="" type="checkbox"> getHfOrderDetailsByClientOid
  • <input checked="" disabled="" type="checkbox"> getHfTransactionRecords
  • <input checked="" disabled="" type="checkbox"> getActiveHfOrderSymbols

    Rest/Earn/General

  • <input checked="" disabled="" type="checkbox"> subscribeToEarnFixedIncomeProducts
  • <input checked="" disabled="" type="checkbox"> redeemByEarnHoldingId
  • <input checked="" disabled="" type="checkbox"> getEarnRedeemPreviewByHoldingId

    Rest/Earn/KucoinEarn

  • <input checked="" disabled="" type="checkbox"> getEarnSavingsProducts
  • <input checked="" disabled="" type="checkbox"> getEarnFixedIncomeCurrentHoldings
  • <input checked="" disabled="" type="checkbox"> getEarnPromotionProducts

    Rest/Earn/Staking

  • <input checked="" disabled="" type="checkbox"> getKcsStakingProducts
  • <input checked="" disabled="" type="checkbox"> getEarnStakingProducts
  • <input checked="" disabled="" type="checkbox"> getEthStakingProducts

    Rest/VIPLending

  • <input checked="" disabled="" type="checkbox"> getOtcLoanInformation
  • <input checked="" disabled="" type="checkbox"> getOtcLoanAccounts

    Rest/Others

  • <input checked="" disabled="" type="checkbox"> getTimestamp
  • <input checked="" disabled="" type="checkbox"> getStatus
  • <input checked="" disabled="" type="checkbox"> getAnnouncements

Websocket Datafeed

API.websocket.Datafeed

Manage websocket connect/private/subscribe/unsubscribe and get realtime datafeed.

DEMO: demo/ticker_demo.js

API.websocket.Level2

Get realtime orderbook in level2 datafeed.

DEMO: demo/level2_demo.js

API.websocket.Level3

test exp

yarn test

// TODO

LICENSE

Apache-2.0 License

changelog

[1.1.1] - 2024-11-12

Added

  • Spot High-Frequency Upgrade: All users can now use high-frequency interfaces without a whitelist. The system is more stable, and the rate limits are more relaxed.
  • User Type API: Added GET /api/v1/hf/accounts/opened to determine the user type.
  • Fetch Announcements API: Added GET /api/v3/announcements to retrieve news and announcements.

Modified

  • Get Currency Details API: GET /api/v3/currencies/{currency} now includes additional fields: withdrawPrecision, needTag, maxWithdraw, and maxDeposit.
  • Get Currency List API: GET /api/v3/currencies now includes additional fields: withdrawPrecision, needTag, maxWithdraw, and maxDeposit.

Deprecated

  • Get Deposit Address API: Deprecated GET /api/v1/deposit-addresses, replaced by GET /api/v3/deposit-addresses.
  • Get Deposit Address API (V2): Deprecated GET /api/v2/deposit-addresses, replaced by GET /api/v3/deposit-addresses.
  • Apply for Deposit Address API: Deprecated POST /api/v1/deposit-addresses, replaced by POST /api/v3/deposit-address/create.
  • Apply for Withdrawal API: Deprecated POST /api/v1/withdrawals, replaced by POST /api/v3/withdrawals.

[1.1.0] - 2024-06-15

Added APIs

  • GET /api/v3/hf/margin/order/active/symbols
  • GET /api/v3/margin/symbols
  • POST /api/v3/position/update-user-leverage
  • GET /api/v1/otc-loan/loan
  • GET /api/v1/otc-loan/accounts
  • POST /api/v1/earn/orders
  • DELETE /api/v1/earn/orders
  • GET /api/v1/earn/redeem-preview
  • GET /api/v1/earn/saving/products
  • GET /api/v1/earn/hold-assets
  • GET /api/v1/earn/promotion/products
  • GET /api/v1/earn/kcs-staking/products
  • GET /api/v1/earn/staking/products
  • GET /api/v1/earn/eth-staking/products
  • POST /api/v3/hf/margin/order
  • POST /api/v3/hf/margin/order/test
  • DELETE /api/v3/hf/margin/orders/{orderId}
  • DELETE /api/v3/hf/margin/orders/client-order/{clientOid}
  • DELETE /api/v3/hf/margin/orders
  • GET /api/v3/hf/margin/orders/active
  • GET /api/v3/hf/margin/orders/done
  • GET /api/v3/hf/margin/orders/{orderId}
  • GET /api/v3/hf/margin/orders/client-order/{clientOid}
  • GET /api/v3/hf/margin/fills

  • TOPIC: /margin/isolatedPosition (Isolated Margin Position Push)

Modified APIs

  • POST /api/v3/margin/borrow - Added isHf field
  • POST /api/v3/margin/repay - Added isHf field

Deprecated APIs

  • TOPIC: /margin/fundingBook

[1.0.9] - 2024-05-30

Added APIs

Universal Transfer API

  • Added: POST /api/v3/accounts/universal-transfer

Margin Borrowing APIs

  • Added: POST /api/v3/margin/borrow
  • Added: GET /api/v3/margin/borrow

Margin Repayment APIs

  • Added: POST /api/v3/margin/repay
  • Added: GET /api/v3/margin/repay

Margin Interest APIs

  • Added: GET /api/v3/margin/interest

Project APIs

  • Added: GET /api/v3/project/list
  • Added: GET /api/v3/project/marketInterestRate

Purchase APIs

  • Added: POST /api/v3/purchase
  • Added: POST /api/v3/redeem
  • Added: POST /api/v3/lend/purchase/update
  • Added: GET /api/v3/redeem/orders
  • Added: GET /api/v3/purchase/orders

Test Order APIs

  • Added: POST /api/v1/hf/orders/test
  • Added: POST /api/v1/margin/order/test
  • Added: POST /api/v1/orders/test

Deprecated APIs

Margin Borrowing APIs

  • Deprecated: Publish Borrow Order, deprecated POST /api/v1/margin/borrow
  • Deprecated: Query Borrow Orders, deprecated GET /api/v1/margin/borrow
  • Deprecated: Query Repaid Records, deprecated GET /api/v1/margin/borrow/repaid
  • Deprecated: One-Click Repayment, deprecated POST /api/v1/margin/repay/all
  • Deprecated: Single Repayment, deprecated POST /api/v1/margin/repay/single

Margin Lending APIs

  • Deprecated: Publish Lend Order, deprecated POST /api/v1/margin/lend
  • Deprecated: Cancel Lend Order, deprecated DELETE /api/v1/margin/lend/{orderId}
  • Deprecated: Set Auto-Lend, deprecated POST /api/v1/margin/toggle-auto-lend
  • Deprecated: Query Active Lend Orders, deprecated GET /api/v1/margin/lend/active
  • Deprecated: Query Historical Lend Orders, deprecated GET /api/v1/margin/lend/done
  • Deprecated: Query Unsettled Lend Records, deprecated GET /api/v1/margin/lend/trade/unsettled
  • Deprecated: Query Settled Lend Records, deprecated GET /api/v1/margin/lend/trade/settled
  • Deprecated: Asset Lend Records, deprecated GET /api/v1/margin/lend/assets
  • Deprecated: Lend Market Information, deprecated GET /api/v1/margin/market
  • Deprecated: Lending Market Transaction Information, deprecated GET /api/v1/margin/trade/last

Isolated Margin Borrowing APIs

  • Deprecated: Isolated Borrowing, deprecated POST /api/v1/isolated/borrow
  • Deprecated: One-Click Repayment, deprecated POST /api/v1/isolated/repay/all
  • Deprecated: Single Repayment, deprecated POST /api/v1/isolated/repay/single
  • Deprecated: Query Repaid Records, deprecated GET /api/v1/isolated/borrow/repaid
  • Deprecated: Query Outstanding Isolated Borrow Records, deprecated GET /api/v1/isolated/borrow/outstanding
  • Deprecated: Query Outstanding Borrow Records, deprecated GET /api/v1/margin/borrow/outstanding

[1.0.8] - 2024-04-15

Added

  • Added getCurrencyDetail_V3 Request via this endpoint to get the currency details of a specified currency.

[1.0.7] - 2024-01-29

Added

  • Added placeOrder API endpoint for placing a new order.
  • Added cancelOrder API endpoint for cancelling an order by orderId.
  • Added cancelOrderByClientOid API endpoint for cancelling an order by clientOid.
  • Added cancelAllOrders API endpoint for cancelling all orders.
  • Added getOrder API endpoint for getting an order by orderId.
  • Added getOrderByClientOid API endpoint for getting an order by clientOid.
  • Added getOrders API endpoint for getting all orders.
  • Added getOrderDetails API endpoint for getting order details by orderId.
  • Added cancelAllHfOrders Cancel all high-frequency orders
  • Added getMarginCurrencies Get margin currencies
  • Added getEtfInfo Get ETF information

    1.0.5-beta (2023-06-25)

Features

1.0.5-beta (2023-05-31)

Features

1.0.5-beta (2023-05-25)

Features

1.0.5-beta (2023-05-25)

Features