KuCoin JavaScript SDK
Use kucoin-api to read KuCoin market data, manage orders, and consume streams from Node.js. JavaScript and TypeScript use the same clients; request and response types are included.
Choose a client
- SpotClient
- Classic Spot, Margin, funding, transfer, Earn, and Convert REST API calls
- FuturesClient
- Classic Futures market, account, order, position, and funding REST API calls
- WebsocketClient
- Classic and Pro public and private WebSocket subscriptions
- WebsocketAPIClient
- Awaitable Spot, Margin, and Futures order commands
- BrokerClient
- Broker subaccount, transfer, deposit, withdrawal, and rebate calls
- UnifiedAPIClient
- Developing Unified Account REST API surface
Make a first public request
In a Node.js project, install the package once. The REST and WebSocket API examples below use .mjs files so Node.js can run their imports directly.
npm install kucoin-api
REST walkthrough
Read public BTC-USDT Spot data with SpotClient. These public requests require no credentials.
Save the code as rest-public.mjs and run:
node rest-public.mjs
import { SpotClient } from 'kucoin-api'; const client = new SpotClient(); async function main() { try { const response = await client.getServerTime(); console.log('Server time:', response.data); } catch (error) { console.error('Server time request failed:', error); } try { const response = await client.getSymbol({ symbol: 'BTC-USDT', }); console.log('BTC-USDT metadata:', response.data); } catch (error) { console.error('Symbol request failed:', error); } try { const response = await client.getTicker({ symbol: 'BTC-USDT', }); console.log('BTC-USDT ticker:', response.data); } catch (error) { console.error('Ticker request failed:', error); } try { const response = await client.getOrderBookLevel20({ symbol: 'BTC-USDT', }); console.log('Best bid:', response.data.bids[0]); console.log('Best ask:', response.data.asks[0]); } catch (error) { console.error('Order book request failed:', error); } try { const response = await client.getKlines({ symbol: 'BTC-USDT', type: '1hour', }); console.log('Latest candle:', response.data[0]); } catch (error) { console.error('Candles request failed:', error); }} main();Expected response
Market values change on each run. These are the fields to check in the logged output.
| Field | Expected result |
|---|---|
| Server time / metadata | A Unix-millisecond number and the symbol object, including price and size increments. |
| Ticker / best bid / best ask | A ticker object and [price, quantity] decimal-string levels. |
| Latest candle | An array starting with Unix seconds, open, close, high, low, volume, and turnover. The example logs the first returned row. |
WebSocket walkthrough
Connecting to Kucoin's private spot WebSocket streams is straightforward with the WebsocketClient.
- Install the Kucoin JavaScript SDK via NPM:
npm install kucoin-api. - Import the WebsocketClient and create an authenticated instance with your API credentials.
- Configure event handlers for key events such as
open,update,response,reconnect,reconnected,close, andexception. - Subscribe to private topics on the
spotPrivateV1connection key.
In this example, we:
- Subscribe to private spot topics such as trade order updates, balances, and advanced orders.
- Subscribe to private margin topics (including isolated margin position updates) on the same private ws key.
- Demonstrate grouped topic subscription in batched requests.
This setup lets you track private account activity in real time without polling REST endpoints.
import { WebsocketClient } from 'kucoin-api'; async function start() { // Optional: inject a custom logger to override internal logging behaviour // const logger: typeof DefaultLogger = { // ...DefaultLogger, // trace: (...params) => { // if ( // [ // 'Sending ping', // // 'Sending upstream ws message: ', // 'Received pong', // ].includes(params[0]) // ) { // return; // } // console.log('trace', JSON.stringify(params, null, 2)); // }, // }; const account = { key: process.env.API_KEY || 'keyHere', secret: process.env.API_SECRET || 'secretHere', passphrase: process.env.API_PASSPHRASE || 'apiPassPhraseHere', // This is NOT your account password }; console.log('connecting with ', account); const client = new WebsocketClient( { apiKey: account.key, apiSecret: account.secret, apiPassphrase: account.passphrase, }, // logger, ); client.on('open', (data) => { console.log('open: ', data?.wsKey); }); // Data received client.on('update', (data) => { console.info('data received: ', JSON.stringify(data)); }); // Something happened, attempting to reconnect client.on('reconnect', (data) => { console.log('reconnect: ', data); }); // Reconnect successful client.on('reconnected', (data) => { console.log('reconnected: ', data); }); // Connection closed. If unexpected, expect reconnect -> reconnected. client.on('close', (data) => { console.error('close: ', data); }); // Reply to a request, e.g. "subscribe"/"unsubscribe"/"authenticate" client.on('response', (data) => { console.info('response: ', data); // throw new Error('res?'); }); client.on('exception', (data) => { console.error('exception: ', { msg: data.msg, errno: data.errno, code: data.code, syscall: data.syscall, hostname: data.hostname, }); }); try { // Optional: await a connection to be ready before subscribing (this is not necessary) // await client.connect('spotPrivateV1'); // console.log('connected'); /** * For more detailed usage info, refer to the ws-spot-public.ts example. * * Below are some examples for subscribing to private spot & margin websockets. * Note: all "private" websocket topics should use the "spotPrivateV1" wsKey. */ client.subscribe( [ '/market/match:BTC-USDT', '/spotMarket/tradeOrders', '/spotMarket/tradeOrdersV2', '/account/balance', '/spotMarket/advancedOrders', ], 'spotPrivateV1', ); /** * Other margin websocket topics, which also use the "spotPrivateV1" WsKey: */ client.subscribe( [ '/margin/position', '/margin/isolatedPosition:BTC-USDT', '/spotMarket/advancedOrders', ], 'spotPrivateV1', ); } catch (e) { console.error('Subscribe exception: ', e); }} start();WebSocket API walkthrough
WebSocket API commands require API credentials. Set the environment variables shown in the code using credentials for the live environment. This example only constructs the client; it sends no request and places no order. Continue with the maintained example below for supported commands and connection handling.
Save the code as ws-api-setup.mjs and run:
node ws-api-setup.mjs
import { WebsocketAPIClient } from 'kucoin-api'; const credentials = { apiKey: process.env.KUCOIN_API_KEY, apiSecret: process.env.KUCOIN_API_SECRET, apiPass: process.env.KUCOIN_API_PASSPHRASE,}; if (Object.values(credentials).some((value) => !value)) { throw new Error('Set KUCOIN_API_KEY, KUCOIN_API_SECRET, KUCOIN_API_PASSPHRASE before running.');} const wsApi = new WebsocketAPIClient(credentials);console.log('Client configured. No request sent.');KuCoin API JavaScript Tutorial
A practical JavaScript guide to using kucoin-api across the KuCoin REST API, Classic WebSockets, safe Spot and Futures order tests, WebSocket API commands, regions, proxies, and reconnect recovery.
Your app / service
bot, dashboard, worker
kucoin-api
SpotClient, FuturesClient, WebsocketClient, WebsocketAPIClient
KuCoin API
REST API, Classic streams, Pro streams, WebSocket API
Common KuCoin implementation tasks
Start from the behavior you need, not just from REST or WebSocket as a transport. Market-data driven systems should be event driven. Backfill via the REST API once and let WebSockets passively stream new data to you, as it becomes available.
REST API hydration or backfill
Start from the REST API quickstart and endpoint reference, then normalize exchange-specific IDs, timestamps, symbols, and product scope.
Open endpoint referenceWebSocket consumer
Start from the WebSocket quickstart that matches the task boundary, verify subscription acknowledgement semantics, and keep reconnect handling explicit.
Open WebSocket quickstartAgent prompt recipe
Use the AI prompt generator when the task combines REST API hydration, live streams, in-memory state, operational outputs, or strategy code.
Build an agent promptFor coding agents
Give these files to an agent before implementation so it can find the package, examples, task guidance, and safety rules from the normal SDK-page flow.
AI prompt framework
Prompt generator and task recipes for exchange API projects.
llms.txt
Compact discovery file for agents choosing where to start.
llms-full.txt
Full route and implementation guidance index for machine readers.
SDK catalog
Machine-readable package, docs, examples, and task guidance.
Agent skill
Reusable workflow rules for coding agents using exchange APIs.
Endpoint Function Reference
Endpoint maps
Each REST client is a JavaScript class, which provides functions individually mapped to each endpoint available in the exchange's API offering.
The following table shows all methods available in each REST client, whether the method requires authentication (automatically handled if API keys are provided), as well as the exact endpoint each method is connected to.
This can be used to easily find which method to call, once you have found which endpoint you're looking to use.
All REST clients are in the src folder. For usage examples, make sure to check the examples folder.
List of clients:
If anything is missing or wrong, please open an issue or let us know in our Node.js Traders telegram group!
How to use table
Table consists of 4 parts:
- Function name
- AUTH
- HTTP Method
- Endpoint
Function name is the name of the function that can be called through the SDK. Check examples folder in the repo for more help on how to use them!
AUTH is a boolean value that indicates if the function requires authentication - which means you need to pass your API key and secret to the SDK.
HTTP Method shows HTTP method that the function uses to call the endpoint. Sometimes endpoints can have same URL, but different HTTP method so you can use this column to differentiate between them.
Endpoint is the URL that the function uses to call the endpoint. Best way to find exact function you need for the endpoint is to search for URL in this table and find corresponding function name.
SpotClient.ts
This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in SpotClient.ts.
| Function | AUTH | HTTP Method | Endpoint |
|---|---|---|---|
| getMyIp() | GET | api/v1/ip | |
| getServiceStatus() | GET | api/v1/status | |
| getAccountSummary() | 🔐 | GET | api/v2/user-info |
| getKYCRegions() | 🔐 | GET | api/kyc/regions/v4 |
| getApikeyInfo() | 🔐 | GET | api/v1/user/api-key |
| getUserType() | 🔐 | GET | api/v1/hf/accounts/opened |
| getBalances() | 🔐 | GET | api/v1/accounts |
| getAccountDetail() | 🔐 | GET | api/v1/accounts/{accountId} |
| getMarginBalance() | 🔐 | GET | api/v3/margin/accounts |
| getIsolatedMarginBalance() | 🔐 | GET | api/v3/isolated/accounts |
| getTransactions() | 🔐 | GET | api/v1/accounts/ledgers |
| getHFTransactions() | 🔐 | GET | api/v1/hf/accounts/ledgers |
| getHFMarginTransactions() | 🔐 | GET | api/v3/hf/margin/account/ledgers |
| createSubAccount() | 🔐 | POST | api/v2/sub/user/created |
| enableSubAccountMargin() | 🔐 | POST | api/v3/sub/user/margin/enable |
| enableSubAccountFutures() | 🔐 | POST | api/v3/sub/user/futures/enable |
| getSubAccountsV2() | 🔐 | GET | api/v2/sub/user |
| getSubAccountBalance() | 🔐 | GET | api/v1/sub-accounts/{subUserId} |
| getSubAccountBalancesV2() | 🔐 | GET | api/v2/sub-accounts |
| createSubAPI() | 🔐 | POST | api/v1/sub/api-key |
| updateSubAPI() | 🔐 | POST | api/v1/sub/api-key/update |
| getSubAPIs() | 🔐 | GET | api/v1/sub/api-key |
| deleteSubAPI() | 🔐 | DELETE | api/v1/sub/api-key |
| createDepositAddressV3() | 🔐 | POST | api/v3/deposit-address/create |
| getDepositAddressesV3() | 🔐 | GET | api/v3/deposit-addresses |
| getDeposits() | 🔐 | GET | api/v1/deposits |
| getWithdrawalQuotas() | 🔐 | GET | api/v1/withdrawals/quotas |
| submitWithdrawV3() | 🔐 | POST | api/v3/withdrawals |
| cancelWithdrawal() | 🔐 | DELETE | api/v1/withdrawals/{withdrawalId} |
| getWithdrawals() | 🔐 | GET | api/v1/withdrawals |
| getWithdrawalById() | 🔐 | GET | api/v1/withdrawals/{withdrawalId} |
| getTransferable() | 🔐 | GET | api/v1/accounts/transferable |
| submitFlexTransfer() | 🔐 | POST | api/v3/accounts/universal-transfer |
| getBasicUserFee() | 🔐 | GET | api/v1/base-fee |
| getTradingPairFee() | 🔐 | GET | api/v1/trade-fees |
| getAnnouncements() | GET | api/v3/announcements | |
| getCurrency() | GET | api/v3/currencies/{currency} | |
| getCurrencies() | GET | api/v3/currencies | |
| getSymbol() | GET | api/v2/symbols/{symbol} | |
| getSymbols() | GET | api/v2/symbols | |
| getTicker() | GET | api/v1/market/orderbook/level1 | |
| getTickers() | GET | api/v1/market/allTickers | |
| getTradeHistories() | GET | api/v1/market/histories | |
| getKlines() | GET | api/v1/market/candles | |
| getOrderBookLevel20() | GET | api/v1/market/orderbook/level2_20 | |
| getOrderBookLevel100() | GET | api/v1/market/orderbook/level2_100 | |
| getFullOrderBook() | 🔐 | GET | api/v3/market/orderbook/level2 |
| getCallAuctionPartOrderBook() | GET | api/v1/market/orderbook/callauction/level2_{size} | |
| getCallAuctionInfo() | GET | api/v1/market/callauctionData | |
| getFiatPrice() | GET | api/v1/prices | |
| get24hrStats() | GET | api/v1/market/stats | |
| getMarkets() | GET | api/v1/markets | |
| submitHFOrder() | 🔐 | POST | api/v1/hf/orders |
| submitHFOrderSync() | 🔐 | POST | api/v1/hf/orders/sync |
| submitHFOrderTest() | 🔐 | POST | api/v1/hf/orders/test |
| submitHFMultipleOrders() | 🔐 | POST | api/v1/hf/orders/multi |
| submitHFMultipleOrdersSync() | 🔐 | POST | api/v1/hf/orders/multi/sync |
| cancelHFOrder() | 🔐 | DELETE | api/v1/hf/orders/{orderId} |
| cancelHFOrderSync() | 🔐 | DELETE | api/v1/hf/orders/sync/{orderId} |
| cancelHFOrderByClientOId() | 🔐 | DELETE | api/v1/hf/orders/client-order/{clientOid} |
| cancelHFOrderSyncByClientOId() | 🔐 | DELETE | api/v1/hf/orders/sync/client-order/{clientOid} |
| cancelHFOrdersNumber() | 🔐 | DELETE | api/v1/hf/orders/cancel/{orderId} |
| cancelHFAllOrdersBySymbol() | 🔐 | DELETE | api/v1/hf/orders |
| cancelHFAllOrders() | 🔐 | DELETE | api/v1/hf/orders/cancelAll |
| updateHFOrder() | 🔐 | POST | api/v1/hf/orders/alter |
| getHFOrderDetailsByOrderId() | 🔐 | GET | api/v1/hf/orders/{orderId} |
| getHFOrderDetailsByClientOid() | 🔐 | GET | api/v1/hf/orders/client-order/{clientOid} |
| getHFActiveSymbols() | 🔐 | GET | api/v1/hf/orders/active/symbols |
| getHFActiveOrders() | 🔐 | GET | api/v1/hf/orders/active |
| getHFActiveOrdersPaginated() | 🔐 | GET | api/v1/hf/orders/active/page |
| getHFCompletedOrders() | 🔐 | GET | api/v1/hf/orders/done |
| getHFFilledOrders() | 🔐 | GET | api/v1/hf/fills |
| cancelHFOrderAutoSettingQuery() | 🔐 | GET | api/v1/hf/orders/dead-cancel-all/query |
| cancelHFOrderAutoSetting() | 🔐 | POST | api/v1/hf/orders/dead-cancel-all |
| submitStopOrder() | 🔐 | POST | api/v1/stop-order |
| cancelStopOrderByClientOid() | 🔐 | DELETE | api/v1/stop-order/cancelOrderByClientOid |
| cancelStopOrderById() | 🔐 | DELETE | api/v1/stop-order/{orderId} |
| cancelStopOrders() | 🔐 | DELETE | api/v1/stop-order/cancel |
| getStopOrders() | 🔐 | GET | api/v1/stop-order |
| getStopOrderByOrderId() | 🔐 | GET | api/v1/stop-order/{orderId} |
| getStopOrderByClientOid() | 🔐 | GET | api/v1/stop-order/queryOrderByClientOid |
| submitOCOOrder() | 🔐 | POST | api/v3/oco/order |
| cancelOCOOrderById() | 🔐 | DELETE | api/v3/oco/order/{orderId} |
| cancelOCOOrderByClientOid() | 🔐 | DELETE | api/v3/oco/client-order/{clientOid} |
| cancelMultipleOCOOrders() | 🔐 | DELETE | api/v3/oco/orders |
| getOCOOrderByOrderId() | 🔐 | GET | api/v3/oco/order/{orderId} |
| getOCOOrderByClientOid() | 🔐 | GET | api/v3/oco/client-order/{clientOid} |
| getOCOOrderDetails() | 🔐 | GET | api/v3/oco/order/details/{orderId} |
| getOCOOrders() | 🔐 | GET | api/v3/oco/orders |
| getMarginActivePairsV3() | 🔐 | GET | api/v3/margin/symbols |
| getMarginConfigInfo() | GET | api/v1/margin/config | |
| getMarginLeveragedToken() | 🔐 | GET | api/v3/etf/info |
| getMarginMarkPrices() | GET | api/v3/mark-price/all-symbols | |
| getMarginMarkPrice() | GET | api/v1/mark-price/{symbol}/current | |
| getIsolatedMarginSymbolsConfig() | 🔐 | GET | api/v1/isolated/symbols |
| getMarginCollateralRatio() | GET | api/v3/margin/collateralRatio | |
| getMarketAvailableInventory() | GET | api/v3/margin/available-inventory | |
| submitHFMarginOrder() | 🔐 | POST | api/v3/hf/margin/order |
| submitHFMarginOrderTest() | 🔐 | POST | api/v3/hf/margin/order/test |
| cancelHFMarginOrder() | 🔐 | DELETE | api/v3/hf/margin/orders/{orderId} |
| cancelHFMarginOrderByClientOid() | 🔐 | DELETE | api/v3/hf/margin/orders/client-order/{clientOid} |
| cancelHFAllMarginOrders() | 🔐 | DELETE | api/v3/hf/margin/orders |
| getHFMarginOpenSymbols() | 🔐 | GET | api/v3/hf/margin/order/active/symbols |
| getHFActiveMarginOrders() | 🔐 | GET | api/v3/hf/margin/orders/active |
| getHFMarginFilledOrders() | 🔐 | GET | api/v3/hf/margin/orders/done |
| getHFMarginFills() | 🔐 | GET | api/v3/hf/margin/fills |
| getHFMarginOrderByOrderId() | 🔐 | GET | api/v3/hf/margin/orders/{orderId} |
| getHFMarginOrderByClientOid() | 🔐 | GET | api/v3/hf/margin/orders/client-order/{clientOid}?symbol={symbol} |
| addMarginStopOrder() | 🔐 | POST | api/v3/hf/margin/stop-order |
| cancelMarginStopOrderByOrderId() | 🔐 | DELETE | api/v3/hf/margin/stop-order/cancel-by-id?orderId={orderId} |
| cancelMarginStopOrderByClientOid() | 🔐 | DELETE | api/v3/hf/margin/stop-order/cancel-by-clientOid |
| batchCancelMarginStopOrder() | 🔐 | DELETE | api/v3/hf/margin/stop-order/cancel |
| getMarginStopOrdersList() | 🔐 | GET | api/v3/hf/margin/stop-orders |
| getMarginStopOrderByOrderId() | 🔐 | GET | api/v3/hf/margin/stop-order/orderId?orderId={orderId} |
| getMarginStopOrderByClientOid() | 🔐 | GET | api/v3/hf/margin/stop-order/clientOid |
| addMarginOcoOrder() | 🔐 | POST | api/v3/hf/margin/oco-order |
| cancelMarginOcoOrderByOrderId() | 🔐 | DELETE | api/v3/hf/margin/oco-order/cancel-by-id?orderId={orderId} |
| cancelMarginOcoOrderByClientOid() | 🔐 | DELETE | api/v3/hf/margin/oco-order/cancel-by-clientOid |
| batchCancelMarginOcoOrders() | 🔐 | DELETE | api/v3/hf/margin/oco-order/cancel |
| getMarginOcoOrderByClientOid() | 🔐 | GET | api/v3/hf/margin/oco-order/clientOid |
| getMarginOcoOrderDetailByOrderId() | 🔐 | GET | api/v3/hf/margin/oco-order/detail/orderId?orderId={orderId} |
| getBorrowInterestRate() | 🔐 | GET | api/v3/margin/borrowRate |
| marginBorrowV3() | 🔐 | POST | api/v3/margin/borrow |
| getMarginBorrowHistoryV3() | 🔐 | GET | api/v3/margin/borrow |
| marginRepayV3() | 🔐 | POST | api/v3/margin/repay |
| getMarginRepayHistoryV3() | 🔐 | GET | api/v3/margin/repay |
| getMarginInterestRecordsV3() | 🔐 | GET | api/v3/margin/interest |
| updateMarginLeverageV3() | 🔐 | POST | api/v3/position/update-user-leverage |
| getLendingCurrencyV3() | GET | api/v3/project/list | |
| getLendingInterestRateV3() | GET | api/v3/project/marketInterestRate | |
| submitLendingSubscriptionV3() | 🔐 | POST | api/v3/purchase |
| updateLendingSubscriptionOrdersV3() | 🔐 | POST | api/v3/lend/purchase/update |
| getLendingSubscriptionOrdersV3() | 🔐 | GET | api/v3/purchase/orders |
| submitLendingRedemptionV3() | 🔐 | POST | api/v3/redeem |
| getLendingRedemptionOrdersV3() | 🔐 | GET | api/v3/redeem/orders |
| getMarginRiskLimitConfig() | 🔐 | GET | api/v3/margin/currencies |
| getConvertSymbol() | GET | api/v1/convert/symbol | |
| getConvertCurrencies() | GET | api/v1/convert/currencies | |
| submitConvertOrder() | 🔐 | POST | api/v1/convert/order |
| getConvertQuote() | 🔐 | GET | api/v1/convert/quote |
| getConvertOrder() | 🔐 | GET | api/v1/convert/order/detail |
| getConvertOrderHistory() | 🔐 | GET | api/v1/convert/order/history |
| submitConvertLimitOrder() | 🔐 | POST | api/v1/convert/limit/order |
| getConvertLimitQuote() | 🔐 | GET | api/v1/convert/limit/quote |
| getConvertLimitOrder() | 🔐 | GET | api/v1/convert/limit/order/detail |
| getConvertLimitOrders() | 🔐 | GET | api/v1/convert/limit/orders |
| cancelConvertLimitOrder() | 🔐 | DELETE | api/v1/convert/limit/order/cancel |
| subscribeEarnFixedIncome() | 🔐 | POST | api/v1/earn/orders |
| getEarnRedeemPreview() | 🔐 | GET | api/v1/earn/redeem-preview |
| submitRedemption() | 🔐 | DELETE | api/v1/earn/orders |
| getEarnSavingsProducts() | 🔐 | GET | api/v1/earn/saving/products |
| getEarnPromotionProducts() | 🔐 | GET | api/v1/earn/promotion/products |
| getEarnFixedIncomeHoldAssets() | 🔐 | GET | api/v1/earn/hold-assets |
| getEarnStakingProducts() | 🔐 | GET | api/v1/earn/staking/products |
| getEarnKcsStakingProducts() | 🔐 | GET | api/v1/earn/kcs-staking/products |
| getEarnEthStakingProducts() | 🔐 | GET | api/v1/earn/eth-staking/products |
| submitStructuredProductPurchase() | 🔐 | POST | api/v1/struct-earn/orders |
| getDualInvestmentProducts() | GET | api/v1/struct-earn/dual/products | |
| getStructuredProductOrders() | 🔐 | GET | api/v1/struct-earn/orders |
| getDiscountRateConfigs() | 🔐 | GET | api/v1/otc-loan/discount-rate-configs |
| getOtcLoan() | 🔐 | GET | api/v1/otc-loan/loan |
| getOtcLoanAccounts() | 🔐 | GET | api/v1/otc-loan/accounts |
| getAffiliateUserRebateInfo() | 🔐 | GET | api/v2/affiliate/inviter/statistics |
| getAffiliateInvitees() | 🔐 | GET | api/v2/affiliate/queryInvitees |
| getAffiliateCommission() | 🔐 | GET | api/v2/affiliate/queryMyCommission |
| getAffiliateTradeHistory() | 🔐 | GET | api/v2/affiliate/queryTransactionByUid |
| getAffiliateTransaction() | 🔐 | GET | api/v2/affiliate/queryTransactionByTime |
| getKumining() | 🔐 | GET | api/v2/affiliate/queryKumining |
| getBrokerRebateOrderDownloadLink() | 🔐 | GET | api/v1/broker/api/rebase/download |
| getBrokerRebateOrderDownloadLinkV2() | 🔐 | GET | api/v2/broker/api/rebase/download |
| getPublicWSConnectionToken() | POST | api/v1/bullet-public | |
| getPrivateWSConnectionToken() | 🔐 | POST | api/v1/bullet-private |
| getPrivateWSConnectionTokenV2() | 🔐 | POST | api/v2/bullet-private |
| getSubAccountsV1() | 🔐 | GET | api/v1/sub/user |
| getSubAccountBalancesV1() | 🔐 | GET | api/v1/sub-accounts |
| getMarginBalances() | 🔐 | GET | api/v1/margin/account |
| createDepositAddress() | 🔐 | POST | api/v1/deposit-addresses |
| getDepositAddressesV2() | 🔐 | GET | api/v2/deposit-addresses |
| getDepositAddressV1() | 🔐 | GET | api/v1/deposit-addresses |
| getHistoricalDepositsV1() | 🔐 | GET | api/v1/hist-deposits |
| getHistoricalWithdrawalsV1() | 🔐 | GET | api/v1/hist-withdrawals |
| submitWithdraw() | 🔐 | POST | api/v1/withdrawals |
| submitTransferMasterSub() | 🔐 | POST | api/v2/accounts/sub-transfer |
| submitInnerTransfer() | 🔐 | POST | api/v2/accounts/inner-transfer |
| submitOrder() | 🔐 | POST | api/v1/orders |
| submitOrderTest() | 🔐 | POST | api/v1/orders/test |
| submitMultipleOrders() | 🔐 | POST | api/v1/orders/multi |
| cancelOrderById() | 🔐 | DELETE | api/v1/orders/{orderId} |
| cancelOrderByClientOid() | 🔐 | DELETE | api/v1/order/client-order/{clientOid} |
| cancelAllOrders() | 🔐 | DELETE | api/v1/orders |
| getOrders() | 🔐 | GET | api/v1/orders |
| getRecentOrders() | 🔐 | GET | api/v1/limit/orders |
| getOrderByOrderId() | 🔐 | GET | api/v1/orders/{orderId} |
| getOrderByClientOid() | 🔐 | GET | api/v1/order/client-order/{clientOid} |
| getFills() | 🔐 | GET | api/v1/fills |
| getRecentFills() | 🔐 | GET | api/v1/limit/fills |
| submitMarginOrder() | 🔐 | POST | api/v1/margin/order |
| submitMarginOrderTest() | 🔐 | POST | api/v1/margin/order/test |
| getIsolatedMarginAccounts() | 🔐 | GET | api/v1/isolated/accounts |
| getIsolatedMarginAccount() | 🔐 | GET | api/v1/isolated/account/{symbol} |
FuturesClient.ts
This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in FuturesClient.ts.
| Function | AUTH | HTTP Method | Endpoint |
|---|---|---|---|
| getBalance() | 🔐 | GET | api/v1/account-overview |
| getTransactions() | 🔐 | GET | api/v1/transaction-history |
| getSubBalances() | 🔐 | GET | api/v1/account-overview-all |
| getTradingPairFee() | 🔐 | GET | api/v1/trade-fees |
| getSymbol() | GET | api/v1/contracts/{symbol} | |
| getSymbols() | GET | api/v1/contracts/active | |
| getTicker() | GET | api/v1/ticker | |
| getTickers() | GET | api/v1/allTickers | |
| getFullOrderBookLevel2() | GET | api/v1/level2/snapshot | |
| getPartOrderBookLevel2Depth20() | GET | api/v1/level2/depth20 | |
| getPartOrderBookLevel2Depth100() | GET | api/v1/level2/depth100 | |
| getMarketTrades() | GET | api/v1/trade/history | |
| getKlines() | GET | api/v1/kline/query | |
| getMarkPrice() | GET | api/v1/mark-price/{symbol}/current | |
| getIndex() | GET | api/v1/index/query | |
| getInterestRates() | GET | api/v1/interest/query | |
| getPremiumIndex() | GET | api/v1/premium/query | |
| get24HourTransactionVolume() | GET | api/v1/trade-statistics | |
| getServiceStatus() | GET | api/v1/status | |
| submitOrder() | 🔐 | POST | api/v1/orders |
| submitNewOrderTest() | 🔐 | POST | api/v1/orders/test |
| submitMultipleOrders() | 🔐 | POST | api/v1/orders/multi |
| submitSLTPOrder() | 🔐 | POST | api/v1/st-orders |
| cancelOrderById() | 🔐 | DELETE | api/v1/orders/{orderId} |
| cancelOrderByClientOid() | 🔐 | DELETE | api/v1/orders/client-order/{clientOid} |
| batchCancelOrders() | 🔐 | DELETE | api/v1/orders/multi-cancel |
| cancelAllOrdersV3() | 🔐 | DELETE | api/v3/orders |
| cancelAllStopOrders() | 🔐 | DELETE | api/v1/stopOrders |
| getOrderByOrderId() | 🔐 | GET | api/v1/orders/{orderId} |
| getOrderByClientOrderId() | 🔐 | GET | api/v1/orders/byClientOid |
| getOrders() | 🔐 | GET | api/v1/orders |
| getRecentOrders() | 🔐 | GET | api/v1/recentDoneOrders |
| getStopOrders() | 🔐 | GET | api/v1/stopOrders |
| getOpenOrderStatistics() | 🔐 | GET | api/v1/openOrderStatistics |
| getRecentFills() | 🔐 | GET | api/v1/recentFills |
| getFills() | 🔐 | GET | api/v1/fills |
| getMarginMode() | 🔐 | GET | api/v2/position/getMarginMode |
| updateMarginMode() | 🔐 | POST | api/v2/position/changeMarginMode |
| batchSwitchMarginMode() | 🔐 | POST | api/v2/position/batchChangeMarginMode |
| getMaxOpenSize() | 🔐 | GET | api/v2/getMaxOpenSize |
| getPosition() | 🔐 | GET | api/v1/position |
| getPositionV2() | 🔐 | GET | api/v2/position |
| getPositions() | 🔐 | GET | api/v1/positions |
| getHistoryPositions() | 🔐 | GET | api/v1/history-positions |
| getMaxWithdrawMargin() | 🔐 | GET | api/v1/margin/maxWithdrawMargin |
| getCrossMarginLeverage() | 🔐 | GET | api/v2/getCrossUserLeverage |
| changeCrossMarginLeverage() | 🔐 | POST | api/v2/changeCrossUserLeverage |
| depositMargin() | 🔐 | POST | api/v1/position/margin/deposit-margin |
| getCrossMarginRiskLimit() | 🔐 | GET | api/v2/batchGetCrossOrderLimit |
| withdrawMargin() | 🔐 | POST | api/v1/margin/withdrawMargin |
| getCrossMarginRequirement() | 🔐 | GET | api/v2/getCrossModeMarginRequirement |
| getRiskLimitLevel() | 🔐 | GET | api/v1/contracts/risk-limit/{symbol} |
| updateRiskLimitLevel() | 🔐 | POST | api/v1/position/risk-limit-level/change |
| getPositionMode() | 🔐 | GET | api/v2/position/getPositionMode |
| updatePositionMode() | 🔐 | POST | api/v2/position/switchPositionMode |
| getFundingRate() | 🔐 | GET | api/v1/funding-rate/{symbol}/current |
| getFundingRates() | 🔐 | GET | api/v1/contract/funding-rates |
| getFundingHistory() | 🔐 | GET | api/v1/funding-history |
| submitCopyTradeOrder() | 🔐 | POST | api/v1/copy-trade/futures/orders |
| submitCopyTradeOrderTest() | 🔐 | POST | api/v1/copy-trade/futures/orders/test |
| submitCopyTradeSLTPOrder() | 🔐 | POST | api/v1/copy-trade/futures/st-orders |
| cancelCopyTradeOrderById() | 🔐 | DELETE | api/v1/copy-trade/futures/orders |
| cancelCopyTradeOrderByClientOid() | 🔐 | DELETE | api/v1/copy-trade/futures/orders/client-order |
| getCopyTradeMaxOpenSize() | 🔐 | GET | api/v1/copy-trade/futures/get-max-open-size |
| getCopyTradeMaxWithdrawMargin() | 🔐 | GET | api/v1/copy-trade/futures/position/margin/max-withdraw-margin |
| addCopyTradeIsolatedMargin() | 🔐 | POST | api/v1/copy-trade/futures/position/margin/deposit-margin |
| removeCopyTradeIsolatedMargin() | 🔐 | POST | api/v1/copy-trade/futures/position/margin/withdraw-margin |
| modifyCopyTradeRiskLimitLevel() | 🔐 | POST | api/v1/copy-trade/futures/position/risk-limit-level/change |
| updateCopyTradeAutoDepositStatus() | 🔐 | POST | api/v1/copy-trade/futures/position/margin/auto-deposit-status |
| switchCopyTradeMarginMode() | 🔐 | POST | api/v1/copy-trade/futures/position/changeMarginMode |
| updateCopyTradeCrossMarginLeverage() | 🔐 | POST | api/v2/copy-trade/futures/changeCrossUserLeverage |
| getCopyTradeCrossMarginRequirement() | 🔐 | POST | api/v2/copy-trade/getCrossModeMarginRequirement |
| switchCopyTradePositionMode() | 🔐 | POST | api/v2/copy-trade/position/switchPositionMode |
| getBrokerRebateOrderDownloadLink() | 🔐 | GET | api/v1/broker/api/rebase/download |
| getBrokerRebateOrderDownloadLinkV2() | 🔐 | GET | api/v2/broker/api/rebase/download |
| getPublicWSConnectionToken() | POST | api/v1/bullet-public | |
| getPrivateWSConnectionToken() | 🔐 | POST | api/v1/bullet-private |
| getPrivateWSConnectionTokenV2() | 🔐 | POST | api/v2/bullet-private |
| submitTransferOut() | 🔐 | POST | api/v3/transfer-out |
| submitTransferIn() | 🔐 | POST | api/v1/transfer-in |
| getTransfers() | 🔐 | GET | api/v1/transfer-list |
| updateAutoDepositStatus() | 🔐 | POST | api/v1/position/margin/auto-deposit-status |
WebsocketAPIClient.ts
This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in WebsocketAPIClient.ts.
| Function | AUTH | HTTP Method | Endpoint |
|---|---|---|---|
| submitNewSpotOrder() | 🔐 | WS | spot.order |
| modifySpotOrder() | 🔐 | WS | spot.modify |
| cancelSpotOrder() | 🔐 | WS | spot.cancel |
| submitSyncSpotOrder() | 🔐 | WS | spot.sync_order |
| cancelSyncSpotOrder() | 🔐 | WS | spot.sync_cancel |
| submitMarginOrder() | 🔐 | WS | margin.order |
| cancelMarginOrder() | 🔐 | WS | margin.cancel |
| submitFuturesOrder() | 🔐 | WS | futures.order |
| cancelFuturesOrder() | 🔐 | WS | futures.cancel |
| submitMultipleFuturesOrders() | 🔐 | WS | futures.multi_order |
| amendFuturesOrder() | 🔐 | WS | uta.amend |
| cancelMultipleFuturesOrders() | 🔐 | WS | futures.multi_cancel |
UnifiedAPIClient.ts
This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in UnifiedAPIClient.ts.
| Function | AUTH | HTTP Method | Endpoint |
|---|---|---|---|
| getAnnouncements() | GET | api/ua/v2/market/announcement | |
| getCurrency() | GET | api/ua/v2/market/currency | |
| getCurrencies() | GET | api/ua/v2/asset/currencies | |
| getThirdPartyCustodyCurrencies() | GET | api/ua/v2/oes/currency | |
| getSymbols() | GET | api/ua/v2/market/instrument | |
| getTickers() | GET | api/ua/v2/market/ticker | |
| getTrades() | GET | api/ua/v2/market/trade | |
| getOrderBook() | GET | api/ua/v2/market/orderbook | |
| getKlines() | GET | api/ua/v2/market/kline | |
| getIndexPrice() | GET | api/ua/v2/market/index-price | |
| getCurrentFundingRate() | GET | api/ua/v2/market/funding-rate | |
| getHistoryFundingRate() | GET | api/ua/v2/market/funding-rate-history | |
| getCrossMarginConfig() | GET | api/ua/v1/market/cross-config | |
| getBorrowableCurrencies() | GET | api/ua/v2/market/borrowable-currency | |
| getServiceStatus() | GET | api/ua/v2/server/status | |
| getClientIPAddress() | GET | api/ua/v2/user/my-ip | |
| getFiatPrice() | GET | api/ua/v2/market/fiat-price | |
| getInterestRateIndex() | GET | api/ua/v2/market/interest-rate-index | |
| getTradeStatistics() | GET | api/ua/v2/trade-statistics | |
| getCallAuctionInfo() | GET | api/ua/v2/market/call-auction-info | |
| getClassicAccount() | 🔐 | GET | api/ua/v2/account/balance |
| getAccount() | 🔐 | GET | api/ua/v2/unified/account/balance |
| getAccountOverview() | 🔐 | GET | api/ua/v2/unified/account/overview |
| getSubAccount() | 🔐 | GET | api/ua/v2/sub-account/balance |
| getSubAccountList() | 🔐 | GET | api/ua/v2/user/sub-account-list |
| getTransferQuotas() | 🔐 | GET | api/ua/v2/account/transfer-quota |
| flexTransfer() | 🔐 | POST | api/ua/v2/account/transfer |
| setSubAccountTransferPermission() | 🔐 | POST | api/ua/v2/sub-account/canTransferOut |
| getAccountMode() | 🔐 | GET | api/ua/v2/account/mode |
| setAccountMode() | 🔐 | POST | api/ua/v2/account/mode |
| getFeeRate() | 🔐 | GET | api/ua/v2/user/fee-rate |
| getAccountLedger() | 🔐 | GET | api/ua/v2/account/ledger |
| getInterestHistory() | 🔐 | GET | api/ua/v2/account/interest-history |
| getBorrowingRatesAndLimits() | 🔐 | GET | api/ua/v2/account/interest-limits |
| modifyLeverage() | 🔐 | POST | api/ua/v2/unified/account/modify-leverage |
| modifyMarginCrossLeverage() | 🔐 | GET | api/ua/v2/unified/account/leverage |
| getLeverage() | 🔐 | GET | api/ua/v2/unified/account/leverage |
| getDepositAddress() | 🔐 | GET | api/ua/v2/asset/deposit/address |
| getDepositHistory() | 🔐 | GET | api/ua/v2/asset/deposit/history |
| getWithdrawalHistory() | 🔐 | GET | api/ua/v2/asset/withdrawal/history |
| setKcsFeeDeduction() | 🔐 | GET | api/ua/v2/account/fee/kcs-deduct |
| getApiKeyInfo() | 🔐 | GET | api/ua/v2/user/api-key |
| getKYCRegions() | GET | api/ua/v2/user/kyc-region | |
| getRateLimit() | 🔐 | GET | api/ua/v2/rate-limit/query |
| getAllRateLimit() | 🔐 | GET | api/ua/v2/rate-limit/query-all |
| getRateLimitCap() | 🔐 | GET | api/ua/v2/rate-limit/query-cap |
| setSubAccountsRateLimit() | 🔐 | POST | api/ua/v2/rate-limit/set |
| addSubAccount() | 🔐 | POST | api/ua/v2/user/sub/create-sub-account |
| addSubAccountApi() | 🔐 | POST | api/ua/v2/user/create-sub-api-key |
| getWithdrawalQuotas() | 🔐 | GET | api/ua/v2/withdrawals/quotas |
| submitWithdraw() | 🔐 | POST | api/ua/v2/withdrawal |
| cancelWithdrawal() | 🔐 | DELETE | api/ua/v2/withdrawal |
| getThirdPartyCustodyQuota() | 🔐 | GET | api/ua/v2/oes/custody-quota |
| placeOrder() | 🔐 | POST | api/ua/v2/unified/order/amend |
| amendOrder() | 🔐 | POST | api/ua/v2/unified/order/amend |
| batchPlaceOrder() | 🔐 | POST | api/ua/v2/unified/order/cancel-all |
| getOrderDetails() | 🔐 | POST | api/ua/v2/unified/order/cancel-all |
| getOpenOrderList() | 🔐 | POST | api/ua/v2/unified/order/cancel-all |
| getOrderHistory() | 🔐 | POST | api/ua/v2/unified/order/cancel-all |
| getTradeHistory() | 🔐 | POST | api/ua/v2/unified/order/cancel-all |
| cancelOrder() | 🔐 | POST | api/ua/v2/unified/order/cancel-all |
| batchCancelOrders() | 🔐 | POST | api/ua/v2/unified/order/cancel-all |
| batchCancelOrdersBySymbol() | 🔐 | POST | api/ua/v2/unified/order/cancel-all |
| setDCP() | 🔐 | POST | api/ua/v1/dcp/set |
| getDCP() | 🔐 | GET | api/ua/v1/dcp/query |
| getPositionList() | 🔐 | GET | api/ua/v2/unified/position/open-list |
| batchModifyMarginMode() | 🔐 | POST | api/ua/v2/unified/position/margin-mode |
| modifyIsolatedFuturesMargin() | 🔐 | POST | api/ua/v2/unified/position/modify-margin |
| getPositionsHistory() | 🔐 | GET | api/ua/v2/position/history |
| getPrivateFundingFeeHistory() | 🔐 | GET | api/ua/v2/position/funding-history |
KuCoin JavaScript FAQ
What does the KuCoin JavaScript SDK cover?
KuCoin supports Spot, Futures, Margin, Lending, WebSockets, and WebSocket API workflows. The JavaScript guide covers the main REST and WebSocket integration patterns.
How do I authenticate private KuCoin API calls in JavaScript?
The public REST example above needs no credentials. For private calls, follow the authentication setup for kucoin-api in the full tutorial, including the credentials or signer required by your exchange.
KuCoin authentication and setupDoes the KuCoin JavaScript SDK help with WebSocket connection management?
Yes. Use the SDK WebSocket client for subscriptions, reconnect handling, and stream lifecycle management instead of building raw socket flows yourself.
When should I use the KuCoin WebSocket API instead of REST?
Use REST for standard request and response workflows such as account queries and order management. Use the WebSocket API flow when you want persistent low-latency interactions over a connected session.
Direct Example Files
Open the example files below for JavaScript and TypeScript-compatible request, authentication, WebSocket, and Node.js service patterns.