KuCoin JavaScript SDK

Installation and integration guidance for the KuCoin SDK in JavaScript.

JavaScript SDK Usage

Use framework-neutral JavaScript request and event flows across Node.js-compatible runtimes.

In JavaScript, use the package directly from readable examples. TypeScript remains useful for larger integrations, but the same client patterns work in plain JavaScript.

What This SDK Covers

  • Complete KuCoin REST API integrations for exchange-specific workflows.
  • Robust KuCoin WebSocket support for market and account stream handling.
  • JavaScript-friendly usage patterns for production integration work.
  • Adaptable JavaScript examples & guides under /examples for implementation reference.
  • Framework-neutral JavaScript snippets that stay approachable in all JavaScript runtimes.

Install Package

npm install kucoin-api
# or
pnpm install kucoin-api
yarn add kucoin-api

Quickstart REST API Walkthrough

Easily start working the Kucoin REST APIs in JavaScript.

  • Install the Kucoin JavaScript SDK via NPM: npm install kucoin-api.
  • Import the FuturesClient class (REST API wrapper for Kucoin futures endpoints).
  • Note: If spot is preferred, use the SpotClient class intead.
  • Create an authenticated FuturesClient instance with your API credentials.
  • Call REST API methods as functions and await their responses.

In this example, we:

  • Fetch contract metadata for XRPUSDTM and read the multiplier.
  • Demonstrate how contract multiplier affects position sizing calculations.
  • Provide practical order payload examples for market and limit long/short entries.
  • Provide practical order payload examples for market and limit close-position requests.
  • Provide practical order payload examples for stop-loss style close orders.

This script is designed as a practical futures order guide, showing how to structure different order requests and reason about contract size before submitting live orders.

For a full map of available REST API methods, check out the endpoint reference below.

Quickstart REST API Example

import { FuturesClient } from 'kucoin-api';

async function start() {
  const account = {
    key: 'keyHere',
    secret: 'secretHere',
    passphrase: 'memoHere',
  };
  const client = new FuturesClient({
    apiKey: account.key,
    apiSecret: account.secret,
    apiPassphrase: account.passphrase,
  });

  try {
    /**
     * =======
     * Credits for this guide go to user: @DKTradingClient / Code Nerd from the Kucoin API Telegram group!
     * =======

    /**
     * Futures are contracts, not currencies. In the futures symbols list you will see a "multiplier" field for each of the symbols. 
     * Each contract equals to  Multiplier x Size
     * For example:  https://api-futures.kucoin.com/api/v1/contracts/XRPUSDTM  - see the "multiplier" value.
     * */

    const symbolInfo = await client.getSymbol({ symbol: 'XRPUSDTM' });
    const multiplier = symbolInfo.data.multiplier;

    /**
     * E.g. if multiplier is 10(what you can see from the endpoint), that means each SIZE is 10 XRP. So if XRP is currently at $0.5,
     * then each 1 contract (size 10) is going to cost $5.00
     * size = (Funds x leverage) / (price x multiplier)
     */

    const XRPPriceExample = 0.5;
    const leverage = 5;
    const fundsToTradeUSDT = 100;

    const costOfContract = XRPPriceExample * multiplier;

    const size = (fundsToTradeUSDT * leverage) / costOfContract;
    console.log(`Size: ${size}`);

    /**
     * The trade amount indicates the amount of contract to buy or sell, and contract uses the base currency or lot as the trading unit.
     * The trade amount must be no less than 1 lot for the contract and no larger than the maxOrderQty.
     * It should be a multiple number of the lot, or the system will report an error when you place the order.
     * E.g. 1 lot of XBTUSDTM is 0.001 Bitcoin, while 1 lot of XBTUSDM is 1 USD.
     * or check the XRPUSDTM example above.
     *
     * Here are function examples using the Futures Create Order endpoint:
     */

    // A MARKET SHORT of 2 contracts of XBT using leverage of 5:
    const marketShort = client.submitOrder({
      clientOid: '123456789',
      leverage: 5,
      side: 'sell',
      size: 2,
      symbol: 'XBTUSDTM',
      timeInForce: 'GTC',
      type: 'market',
    });
    console.log('Market short: ', marketShort);

    // A MARKET LONG of 2 contracts of XBT using leverage of 5:
    const marketLong = client.submitOrder({
      clientOid: '123456789',
      leverage: 5,
      side: 'buy',
      size: 2,
      symbol: 'XBTUSDTM',
      timeInForce: 'GTC',
      type: 'market',
    });
    console.log('Market long: ', marketLong);

    // A LIMIT SHORT of 2 contracts of XBT using leverage of 5:
    const limitShort = client.submitOrder({
      clientOid: '123456789',
      leverage: 5,
      price: '70300.31',
      side: 'sell',
      size: 2,
      symbol: 'XBTUSDTM',
      timeInForce: 'GTC',
      type: 'limit',
    });
    console.log('Limit short: ', limitShort);

    // A LIMIT LONG of 2 contracts of XBT using leverage of 5:
    const limitLong = client.submitOrder({
      clientOid: '123456789',
      leverage: 5,
      price: '40300.31',
      side: 'buy',
      size: 2,
      symbol: 'XBTUSDTM',
      timeInForce: 'GTC',
      type: 'limit',
    });
    console.log('Limit long: ', limitLong);
    // On any "close position" action, if you specify a SIZE=0 or leave off the SIZE parameter,
    // then it will close the whole position, regardless of the size.
    // If you specify a SIZE, it will close only the number of contracts you specify.

    // If closeOrder is set to TRUE,
    // the system will close the position and the position size will become 0.
    // Side, Size and Leverage fields can be left empty and the system will determine the side and size automatically.

    // A MARKET CLOSE POSITION example:
    const marketClose = client.submitOrder({
      clientOid: '123456789',
      closeOrder: true,
      symbol: 'XBTUSDTM',
      timeInForce: 'GTC',
      type: 'market',
      side: 'sell',
      size: 0,
    });
    console.log('Market close: ', marketClose);

    // A LIMIT CLOSE of a LONG example:
    const limitCloseLong = client.submitOrder({
      clientOid: '123456789',
      leverage: 5,
      price: '70300.31',
      closeOrder: true,
      side: 'sell',
      size: 2,
      symbol: 'XBTUSDTM',
      timeInForce: 'GTC',
      type: 'limit',
    });
    console.log('Limit close long: ', limitCloseLong);

    // A LIMIT CLOSE of a SHORT example:
    const limitCloseShort = client.submitOrder({
      clientOid: '123456789',
      leverage: 5,
      price: '40300.31',
      closeOrder: true,
      side: 'buy',
      size: 2,
      symbol: 'XBTUSDTM',
      timeInForce: 'GTC',
      type: 'limit',
    });
    console.log('Limit close short: ', limitCloseShort);

    // A STOP LOSS example for a LONG position:
    const stopLossLong = client.submitOrder({
      clientOid: '123456789',
      closeOrder: true,
      stop: 'down',
      side: 'buy',
      stopPrice: '40200.31',
      stopPriceType: 'TP',
      symbol: 'XBTUSDTM',
      timeInForce: 'GTC',
      type: 'market',
    });
    console.log('Stoploss long: ', stopLossLong);

    // A STOP LOSS example for a SHORT position:
    const stopLossShort = client.submitOrder({
      clientOid: '123456789',
      closeOrder: true,
      stop: 'up',
      side: 'sell',
      stopPrice: '40200.31',
      stopPriceType: 'TP',
      symbol: 'XBTUSDTM',
      timeInForce: 'GTC',
      type: 'market',
    });

    console.log('Stoploss short: ', stopLossShort);
  } catch (e) {
    console.error('Req error: ', e);
  }
}

start();

Quickstart 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, and exception.
  • Subscribe to private topics on the spotPrivateV1 connection 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.

Quickstart WebSocket Example

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 reconenct
  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();

Quickstart WebSocket API Walkthrough

Kucoin's WebSocket API (WS-API) lets you send trading commands over persistent authenticated WebSocket connections, reducing overhead compared to repeatedly opening REST requests.

The SDK's WebsocketAPIClient wraps this with promise-based methods so each command can be awaited similarly to a REST call.

To use the WebSocket API:

  • Install the Kucoin JavaScript SDK via NPM: npm install kucoin-api.
  • Import the dedicated WebsocketAPIClient.
  • Create an authenticated WebsocketAPIClient instance with your API credentials.
  • Optionally customize logging with the injected logger.
  • Call dedicated WS-API helper methods and await each response.

In this example, we:

  • Submit, sync-submit, modify, cancel, and query spot orders.
  • Submit and cancel margin orders.
  • Submit, cancel, batch-submit, and batch-cancel futures orders.

Note that:

  • The script is a broad capability walkthrough and includes placeholder order IDs that should be replaced for live use.
  • Operations are wrapped in independent try/catch blocks so each WS-API request can be tested separately.

Quickstart WebSocket API Example

/**
 * KuCoin WebSocket API Client - Complete Example
 *
 * This example demonstrates all available WebSocket API operations:
 * - Spot trading: submit, modify, cancel, sync operations
 * - Margin trading: submit and cancel orders
 * - Futures trading: submit, cancel, batch operations
 *
 * Usage:
 * Make sure to set your API credentials in environment variables:
 *    - API_KEY
 *    - API_SECRET
 *    - API_PASSPHRASE
 *
 *  or pass them as arguments to the constructor
 */

import { DefaultLogger, WebsocketAPIClient } from 'kucoin-api';

async function main() {
  const customLogger = {
    ...DefaultLogger,
    // For a more detailed view of the WebsocketClient, enable the `trace` level by uncommenting the below line:
    // trace: (...params) => console.log(new Date(), 'trace', ...params),
  };

  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
  };

  const wsClient = new WebsocketAPIClient(
    {
      apiKey: account.key,
      apiSecret: account.secret,
      apiPassphrase: account.passphrase,

      // If you want your own event handlers instead of the default ones with logs, disable this setting and see the `attachEventHandlers` example below:
      // attachEventListeners: false
    },
    customLogger,
  );

  // Example usage for each WebSocket API operation
  console.log('Starting WebSocket API examples...\n');

  // 1. Submit Spot Order
  try {
    console.log('\n2. Testing submitNewSpotOrder...');
    const spotOrderResponse = await wsClient.submitNewSpotOrder({
      side: 'buy',
      symbol: 'BTC-USDT',
      type: 'limit',
      price: '20000', // Very low price to avoid accidental execution
      size: '0.0001',
    });
    console.log('Spot order response:', spotOrderResponse);
  } catch (e) {
    console.log('Spot order error:', e);
  }

  // 2. Submit Sync Spot Order
  try {
    console.log('\n3. Testing submitSyncSpotOrder...');
    const syncSpotOrderResponse = await wsClient.submitSyncSpotOrder({
      side: 'buy',
      symbol: 'BTC-USDT',
      type: 'limit',
      price: '1000', // Very high price to avoid accidental execution
      size: '0.01',
    });
    console.log('Sync spot order response:', syncSpotOrderResponse);
  } catch (e) {
    console.log('Sync spot order error:', e);
  }

  // 3. Modify Spot Order (requires existing order ID)
  try {
    console.log('\n4. Testing modifySpotOrder...');
    const modifyResponse = await wsClient.modifySpotOrder({
      symbol: 'BTC-USDT',
      orderId: '68cc3476693c1c00072ef1d9', // Replace with actual order ID
      newPrice: '2000',
    });
    console.log('Modify spot order response:', modifyResponse);
  } catch (e) {
    console.log('Modify spot order error:', e);
  }

  // 4. Cancel Spot Order
  try {
    console.log('\n5. Testing cancelSpotOrder...');
    const cancelSpotResponse = await wsClient.cancelSpotOrder({
      symbol: 'BTC-USDT',
      orderId: '68cc34c6693c1c0007301929', // Replace with actual order ID
    });
    console.log('Cancel spot order response:', cancelSpotResponse);
  } catch (e) {
    console.log('Cancel spot order error:', e);
  }

  // 5. Cancel Sync Spot Order
  try {
    console.log('\n6. Testing cancelSyncSpotOrder...');
    const cancelSyncResponse = await wsClient.cancelSyncSpotOrder({
      symbol: 'BTC-USDT',
      orderId: '68cc3530b9870a0007670294', // Replace with actual client order ID
    });
    console.log('Cancel sync spot order response:', cancelSyncResponse);
  } catch (e) {
    console.log('Cancel sync spot order error:', e);
  }

  // 6. Submit Margin Order
  try {
    console.log('\n7. Testing submitMarginOrder...');
    const marginOrderResponse = await wsClient.submitMarginOrder({
      clientOid: 'margin-test-' + Date.now(),
      side: 'buy',
      symbol: 'BTC-USDT',
      type: 'limit',
      price: '19000', // Very low price to avoid accidental execution
      size: '0.0001',
      isIsolated: false, // false for cross margin, true for isolated
    });
    console.log('Margin order response:', marginOrderResponse);
  } catch (e) {
    console.log('Margin order error:', e);
  }

  // 7. Cancel Margin Order
  try {
    console.log('\n8. Testing cancelMarginOrder...');
    const cancelMarginResponse = await wsClient.cancelMarginOrder({
      symbol: 'BTC-USDT',
      orderId: 'your-margin-order-id-here', // Replace with actual order ID
    });
    console.log('Cancel margin order response:', cancelMarginResponse);
  } catch (e) {
    console.log('Cancel margin order error:', e);
  }

  // 8. Submit Futures Order
  try {
    console.log('\n9. Testing submitFuturesOrder...');
    const futuresOrderResponse = await wsClient.submitFuturesOrder({
      clientOid: 'futures-test-' + Date.now(),
      side: 'buy',
      symbol: 'XBTUSDTM',
      marginMode: 'CROSS',
      type: 'limit',
      price: '1000', // Very low price to avoid accidental execution
      qty: '0.01',
      leverage: 10,
      positionSide: 'LONG', // needed if trading two-way (hedge) position mode
    });
    console.log('Futures order response:', futuresOrderResponse);
  } catch (e) {
    console.log('Futures order error:', e);
  }

  // 9. Cancel Futures Order
  try {
    console.log('\n10. Testing cancelFuturesOrder...');
    const cancelFuturesResponse = await wsClient.cancelFuturesOrder({
      symbol: 'XBTUSDTM',
      orderId: '358196976308797441', // Replace with actual order ID
    });
    console.log('Cancel futures order response:', cancelFuturesResponse);
  } catch (e) {
    console.log('Cancel futures order error:', e);
  }

  // 10. Submit Multiple Futures Orders
  try {
    console.log('\n11. Testing submitMultipleFuturesOrders...');
    const multiFuturesResponse = await wsClient.submitMultipleFuturesOrders([
      {
        clientOid: 'futures-test-1-' + Date.now(),
        side: 'buy',
        symbol: 'XBTUSDTM',
        marginMode: 'CROSS',
        type: 'limit',
        price: '1000', // Very low price to avoid accidental execution
        qty: '0.01',
        leverage: 10,
        positionSide: 'LONG', // Needed if trading hedge/two-way mode. Optional in one-way mode.
      },
      {
        clientOid: 'futures-test-2-' + Date.now(),
        side: 'buy',
        symbol: 'XBTUSDTM',
        marginMode: 'CROSS',
        type: 'limit',
        price: '1010', // Very low price to avoid accidental execution
        qty: '0.01',
        leverage: 10,
        positionSide: 'LONG',
      },
    ]);
    console.log('Multiple futures orders response:', multiFuturesResponse);
  } catch (e) {
    console.log('Multiple futures orders error:', e);
  }

  // 11. Cancel Multiple Futures Orders
  try {
    console.log('\n12. Testing cancelMultipleFuturesOrders...');
    const cancelMultiFuturesResponse =
      await wsClient.cancelMultipleFuturesOrders({
        orderIdsList: ['order-id-1', 'order-id-2'], // Replace with actual order IDs
      });
    console.log(
      'Cancel multiple futures orders response:',
      cancelMultiFuturesResponse,
    );
  } catch (e) {
    console.log('Cancel multiple futures orders error:', e);
  }

  console.log('\nCompleted all WebSocket API examples!');
  process.exit(1);
}

// Start executing the example workflow
main();

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.

FunctionAUTHHTTP MethodEndpoint
getMyIp()GETapi/v1/ip
getServiceStatus()GETapi/v1/status
getAccountSummary()🔐GETapi/v2/user-info
getKYCRegions()🔐GETapi/kyc/regions/v4
getApikeyInfo()🔐GETapi/v1/user/api-key
getUserType()🔐GETapi/v1/hf/accounts/opened
getBalances()🔐GETapi/v1/accounts
getAccountDetail()🔐GETapi/v1/accounts/{accountId}
getMarginBalance()🔐GETapi/v3/margin/accounts
getIsolatedMarginBalance()🔐GETapi/v3/isolated/accounts
getTransactions()🔐GETapi/v1/accounts/ledgers
getHFTransactions()🔐GETapi/v1/hf/accounts/ledgers
getHFMarginTransactions()🔐GETapi/v3/hf/margin/account/ledgers
createSubAccount()🔐POSTapi/v2/sub/user/created
enableSubAccountMargin()🔐POSTapi/v3/sub/user/margin/enable
enableSubAccountFutures()🔐POSTapi/v3/sub/user/futures/enable
getSubAccountsV2()🔐GETapi/v2/sub/user
getSubAccountBalance()🔐GETapi/v1/sub-accounts/{subUserId}
getSubAccountBalancesV2()🔐GETapi/v2/sub-accounts
createSubAPI()🔐POSTapi/v1/sub/api-key
updateSubAPI()🔐POSTapi/v1/sub/api-key/update
getSubAPIs()🔐GETapi/v1/sub/api-key
deleteSubAPI()🔐DELETEapi/v1/sub/api-key
createDepositAddressV3()🔐POSTapi/v3/deposit-address/create
getDepositAddressesV3()🔐GETapi/v3/deposit-addresses
getDeposits()🔐GETapi/v1/deposits
getWithdrawalQuotas()🔐GETapi/v1/withdrawals/quotas
submitWithdrawV3()🔐POSTapi/v3/withdrawals
cancelWithdrawal()🔐DELETEapi/v1/withdrawals/{withdrawalId}
getWithdrawals()🔐GETapi/v1/withdrawals
getWithdrawalById()🔐GETapi/v1/withdrawals/{withdrawalId}
getTransferable()🔐GETapi/v1/accounts/transferable
submitFlexTransfer()🔐POSTapi/v3/accounts/universal-transfer
getBasicUserFee()🔐GETapi/v1/base-fee
getTradingPairFee()🔐GETapi/v1/trade-fees
getAnnouncements()GETapi/v3/announcements
getCurrency()GETapi/v3/currencies/{currency}
getCurrencies()GETapi/v3/currencies
getSymbol()GETapi/v2/symbols/{symbol}
getSymbols()GETapi/v2/symbols
getTicker()GETapi/v1/market/orderbook/level1
getTickers()GETapi/v1/market/allTickers
getTradeHistories()GETapi/v1/market/histories
getKlines()GETapi/v1/market/candles
getOrderBookLevel20()GETapi/v1/market/orderbook/level2_20
getOrderBookLevel100()GETapi/v1/market/orderbook/level2_100
getFullOrderBook()🔐GETapi/v3/market/orderbook/level2
getCallAuctionPartOrderBook()GETapi/v1/market/orderbook/callauction/level2_{size}
getCallAuctionInfo()GETapi/v1/market/callauctionData
getFiatPrice()GETapi/v1/prices
get24hrStats()GETapi/v1/market/stats
getMarkets()GETapi/v1/markets
submitHFOrder()🔐POSTapi/v1/hf/orders
submitHFOrderSync()🔐POSTapi/v1/hf/orders/sync
submitHFOrderTest()🔐POSTapi/v1/hf/orders/test
submitHFMultipleOrders()🔐POSTapi/v1/hf/orders/multi
submitHFMultipleOrdersSync()🔐POSTapi/v1/hf/orders/multi/sync
cancelHFOrder()🔐DELETEapi/v1/hf/orders/{orderId}
cancelHFOrderSync()🔐DELETEapi/v1/hf/orders/sync/{orderId}
cancelHFOrderByClientOId()🔐DELETEapi/v1/hf/orders/client-order/{clientOid}
cancelHFOrderSyncByClientOId()🔐DELETEapi/v1/hf/orders/sync/client-order/{clientOid}
cancelHFOrdersNumber()🔐DELETEapi/v1/hf/orders/cancel/{orderId}
cancelHFAllOrdersBySymbol()🔐DELETEapi/v1/hf/orders
cancelHFAllOrders()🔐DELETEapi/v1/hf/orders/cancelAll
updateHFOrder()🔐POSTapi/v1/hf/orders/alter
getHFOrderDetailsByOrderId()🔐GETapi/v1/hf/orders/{orderId}
getHFOrderDetailsByClientOid()🔐GETapi/v1/hf/orders/client-order/{clientOid}
getHFActiveSymbols()🔐GETapi/v1/hf/orders/active/symbols
getHFActiveOrders()🔐GETapi/v1/hf/orders/active
getHFActiveOrdersPaginated()🔐GETapi/v1/hf/orders/active/page
getHFCompletedOrders()🔐GETapi/v1/hf/orders/done
getHFFilledOrders()🔐GETapi/v1/hf/fills
cancelHFOrderAutoSettingQuery()🔐GETapi/v1/hf/orders/dead-cancel-all/query
cancelHFOrderAutoSetting()🔐POSTapi/v1/hf/orders/dead-cancel-all
submitStopOrder()🔐POSTapi/v1/stop-order
cancelStopOrderByClientOid()🔐DELETEapi/v1/stop-order/cancelOrderByClientOid
cancelStopOrderById()🔐DELETEapi/v1/stop-order/{orderId}
cancelStopOrders()🔐DELETEapi/v1/stop-order/cancel
getStopOrders()🔐GETapi/v1/stop-order
getStopOrderByOrderId()🔐GETapi/v1/stop-order/{orderId}
getStopOrderByClientOid()🔐GETapi/v1/stop-order/queryOrderByClientOid
submitOCOOrder()🔐POSTapi/v3/oco/order
cancelOCOOrderById()🔐DELETEapi/v3/oco/order/{orderId}
cancelOCOOrderByClientOid()🔐DELETEapi/v3/oco/client-order/{clientOid}
cancelMultipleOCOOrders()🔐DELETEapi/v3/oco/orders
getOCOOrderByOrderId()🔐GETapi/v3/oco/order/{orderId}
getOCOOrderByClientOid()🔐GETapi/v3/oco/client-order/{clientOid}
getOCOOrderDetails()🔐GETapi/v3/oco/order/details/{orderId}
getOCOOrders()🔐GETapi/v3/oco/orders
getMarginActivePairsV3()🔐GETapi/v3/margin/symbols
getMarginConfigInfo()GETapi/v1/margin/config
getMarginLeveragedToken()🔐GETapi/v3/etf/info
getMarginMarkPrices()GETapi/v3/mark-price/all-symbols
getMarginMarkPrice()GETapi/v1/mark-price/{symbol}/current
getIsolatedMarginSymbolsConfig()🔐GETapi/v1/isolated/symbols
getMarginCollateralRatio()GETapi/v3/margin/collateralRatio
getMarketAvailableInventory()GETapi/v3/margin/available-inventory
submitHFMarginOrder()🔐POSTapi/v3/hf/margin/order
submitHFMarginOrderTest()🔐POSTapi/v3/hf/margin/order/test
cancelHFMarginOrder()🔐DELETEapi/v3/hf/margin/orders/{orderId}
cancelHFMarginOrderByClientOid()🔐DELETEapi/v3/hf/margin/orders/client-order/{clientOid}
cancelHFAllMarginOrders()🔐DELETEapi/v3/hf/margin/orders
getHFMarginOpenSymbols()🔐GETapi/v3/hf/margin/order/active/symbols
getHFActiveMarginOrders()🔐GETapi/v3/hf/margin/orders/active
getHFMarginFilledOrders()🔐GETapi/v3/hf/margin/orders/done
getHFMarginFills()🔐GETapi/v3/hf/margin/fills
getHFMarginOrderByOrderId()🔐GETapi/v3/hf/margin/orders/{orderId}
getHFMarginOrderByClientOid()🔐GETapi/v3/hf/margin/orders/client-order/{clientOid}?symbol={symbol}
addMarginStopOrder()🔐POSTapi/v3/hf/margin/stop-order
cancelMarginStopOrderByOrderId()🔐DELETEapi/v3/hf/margin/stop-order/cancel-by-id?orderId={orderId}
cancelMarginStopOrderByClientOid()🔐DELETEapi/v3/hf/margin/stop-order/cancel-by-clientOid
batchCancelMarginStopOrder()🔐DELETEapi/v3/hf/margin/stop-order/cancel
getMarginStopOrdersList()🔐GETapi/v3/hf/margin/stop-orders
getMarginStopOrderByOrderId()🔐GETapi/v3/hf/margin/stop-order/orderId?orderId={orderId}
getMarginStopOrderByClientOid()🔐GETapi/v3/hf/margin/stop-order/clientOid
addMarginOcoOrder()🔐POSTapi/v3/hf/margin/oco-order
cancelMarginOcoOrderByOrderId()🔐DELETEapi/v3/hf/margin/oco-order/cancel-by-id?orderId={orderId}
cancelMarginOcoOrderByClientOid()🔐DELETEapi/v3/hf/margin/oco-order/cancel-by-clientOid
batchCancelMarginOcoOrders()🔐DELETEapi/v3/hf/margin/oco-order/cancel
getMarginOcoOrderByClientOid()🔐GETapi/v3/hf/margin/oco-order/clientOid
getMarginOcoOrderDetailByOrderId()🔐GETapi/v3/hf/margin/oco-order/detail/orderId?orderId={orderId}
getBorrowInterestRate()🔐GETapi/v3/margin/borrowRate
marginBorrowV3()🔐POSTapi/v3/margin/borrow
getMarginBorrowHistoryV3()🔐GETapi/v3/margin/borrow
marginRepayV3()🔐POSTapi/v3/margin/repay
getMarginRepayHistoryV3()🔐GETapi/v3/margin/repay
getMarginInterestRecordsV3()🔐GETapi/v3/margin/interest
updateMarginLeverageV3()🔐POSTapi/v3/position/update-user-leverage
getLendingCurrencyV3()GETapi/v3/project/list
getLendingInterestRateV3()GETapi/v3/project/marketInterestRate
submitLendingSubscriptionV3()🔐POSTapi/v3/purchase
updateLendingSubscriptionOrdersV3()🔐POSTapi/v3/lend/purchase/update
getLendingSubscriptionOrdersV3()🔐GETapi/v3/purchase/orders
submitLendingRedemptionV3()🔐POSTapi/v3/redeem
getLendingRedemptionOrdersV3()🔐GETapi/v3/redeem/orders
getMarginRiskLimitConfig()🔐GETapi/v3/margin/currencies
getConvertSymbol()GETapi/v1/convert/symbol
getConvertCurrencies()GETapi/v1/convert/currencies
submitConvertOrder()🔐POSTapi/v1/convert/order
getConvertQuote()🔐GETapi/v1/convert/quote
getConvertOrder()🔐GETapi/v1/convert/order/detail
getConvertOrderHistory()🔐GETapi/v1/convert/order/history
submitConvertLimitOrder()🔐POSTapi/v1/convert/limit/order
getConvertLimitQuote()🔐GETapi/v1/convert/limit/quote
getConvertLimitOrder()🔐GETapi/v1/convert/limit/order/detail
getConvertLimitOrders()🔐GETapi/v1/convert/limit/orders
cancelConvertLimitOrder()🔐DELETEapi/v1/convert/limit/order/cancel
subscribeEarnFixedIncome()🔐POSTapi/v1/earn/orders
getEarnRedeemPreview()🔐GETapi/v1/earn/redeem-preview
submitRedemption()🔐DELETEapi/v1/earn/orders
getEarnSavingsProducts()🔐GETapi/v1/earn/saving/products
getEarnPromotionProducts()🔐GETapi/v1/earn/promotion/products
getEarnFixedIncomeHoldAssets()🔐GETapi/v1/earn/hold-assets
getEarnStakingProducts()🔐GETapi/v1/earn/staking/products
getEarnKcsStakingProducts()🔐GETapi/v1/earn/kcs-staking/products
getEarnEthStakingProducts()🔐GETapi/v1/earn/eth-staking/products
submitStructuredProductPurchase()🔐POSTapi/v1/struct-earn/orders
getDualInvestmentProducts()GETapi/v1/struct-earn/dual/products
getStructuredProductOrders()🔐GETapi/v1/struct-earn/orders
getDiscountRateConfigs()🔐GETapi/v1/otc-loan/discount-rate-configs
getOtcLoan()🔐GETapi/v1/otc-loan/loan
getOtcLoanAccounts()🔐GETapi/v1/otc-loan/accounts
getAffiliateUserRebateInfo()🔐GETapi/v2/affiliate/inviter/statistics
getAffiliateInvitees()🔐GETapi/v2/affiliate/queryInvitees
getAffiliateCommission()🔐GETapi/v2/affiliate/queryMyCommission
getAffiliateTradeHistory()🔐GETapi/v2/affiliate/queryTransactionByUid
getAffiliateTransaction()🔐GETapi/v2/affiliate/queryTransactionByTime
getKumining()🔐GETapi/v2/affiliate/queryKumining
getBrokerRebateOrderDownloadLink()🔐GETapi/v1/broker/api/rebase/download
getBrokerRebateOrderDownloadLinkV2()🔐GETapi/v2/broker/api/rebase/download
getPublicWSConnectionToken()POSTapi/v1/bullet-public
getPrivateWSConnectionToken()🔐POSTapi/v1/bullet-private
getPrivateWSConnectionTokenV2()🔐POSTapi/v2/bullet-private
getSubAccountsV1()🔐GETapi/v1/sub/user
getSubAccountBalancesV1()🔐GETapi/v1/sub-accounts
getMarginBalances()🔐GETapi/v1/margin/account
createDepositAddress()🔐POSTapi/v1/deposit-addresses
getDepositAddressesV2()🔐GETapi/v2/deposit-addresses
getDepositAddressV1()🔐GETapi/v1/deposit-addresses
getHistoricalDepositsV1()🔐GETapi/v1/hist-deposits
getHistoricalWithdrawalsV1()🔐GETapi/v1/hist-withdrawals
submitWithdraw()🔐POSTapi/v1/withdrawals
submitTransferMasterSub()🔐POSTapi/v2/accounts/sub-transfer
submitInnerTransfer()🔐POSTapi/v2/accounts/inner-transfer
submitOrder()🔐POSTapi/v1/orders
submitOrderTest()🔐POSTapi/v1/orders/test
submitMultipleOrders()🔐POSTapi/v1/orders/multi
cancelOrderById()🔐DELETEapi/v1/orders/{orderId}
cancelOrderByClientOid()🔐DELETEapi/v1/order/client-order/{clientOid}
cancelAllOrders()🔐DELETEapi/v1/orders
getOrders()🔐GETapi/v1/orders
getRecentOrders()🔐GETapi/v1/limit/orders
getOrderByOrderId()🔐GETapi/v1/orders/{orderId}
getOrderByClientOid()🔐GETapi/v1/order/client-order/{clientOid}
getFills()🔐GETapi/v1/fills
getRecentFills()🔐GETapi/v1/limit/fills
submitMarginOrder()🔐POSTapi/v1/margin/order
submitMarginOrderTest()🔐POSTapi/v1/margin/order/test
getIsolatedMarginAccounts()🔐GETapi/v1/isolated/accounts
getIsolatedMarginAccount()🔐GETapi/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.

FunctionAUTHHTTP MethodEndpoint
getBalance()🔐GETapi/v1/account-overview
getTransactions()🔐GETapi/v1/transaction-history
getSubBalances()🔐GETapi/v1/account-overview-all
getTradingPairFee()🔐GETapi/v1/trade-fees
getSymbol()GETapi/v1/contracts/{symbol}
getSymbols()GETapi/v1/contracts/active
getTicker()GETapi/v1/ticker
getTickers()GETapi/v1/allTickers
getFullOrderBookLevel2()GETapi/v1/level2/snapshot
getPartOrderBookLevel2Depth20()GETapi/v1/level2/depth20
getPartOrderBookLevel2Depth100()GETapi/v1/level2/depth100
getMarketTrades()GETapi/v1/trade/history
getKlines()GETapi/v1/kline/query
getMarkPrice()GETapi/v1/mark-price/{symbol}/current
getIndex()GETapi/v1/index/query
getInterestRates()GETapi/v1/interest/query
getPremiumIndex()GETapi/v1/premium/query
get24HourTransactionVolume()GETapi/v1/trade-statistics
getServiceStatus()GETapi/v1/status
submitOrder()🔐POSTapi/v1/orders
submitNewOrderTest()🔐POSTapi/v1/orders/test
submitMultipleOrders()🔐POSTapi/v1/orders/multi
submitSLTPOrder()🔐POSTapi/v1/st-orders
cancelOrderById()🔐DELETEapi/v1/orders/{orderId}
cancelOrderByClientOid()🔐DELETEapi/v1/orders/client-order/{clientOid}
batchCancelOrders()🔐DELETEapi/v1/orders/multi-cancel
cancelAllOrdersV3()🔐DELETEapi/v3/orders
cancelAllStopOrders()🔐DELETEapi/v1/stopOrders
getOrderByOrderId()🔐GETapi/v1/orders/{orderId}
getOrderByClientOrderId()🔐GETapi/v1/orders/byClientOid
getOrders()🔐GETapi/v1/orders
getRecentOrders()🔐GETapi/v1/recentDoneOrders
getStopOrders()🔐GETapi/v1/stopOrders
getOpenOrderStatistics()🔐GETapi/v1/openOrderStatistics
getRecentFills()🔐GETapi/v1/recentFills
getFills()🔐GETapi/v1/fills
getMarginMode()🔐GETapi/v2/position/getMarginMode
updateMarginMode()🔐POSTapi/v2/position/changeMarginMode
batchSwitchMarginMode()🔐POSTapi/v2/position/batchChangeMarginMode
getMaxOpenSize()🔐GETapi/v2/getMaxOpenSize
getPosition()🔐GETapi/v1/position
getPositionV2()🔐GETapi/v2/position
getPositions()🔐GETapi/v1/positions
getHistoryPositions()🔐GETapi/v1/history-positions
getMaxWithdrawMargin()🔐GETapi/v1/margin/maxWithdrawMargin
getCrossMarginLeverage()🔐GETapi/v2/getCrossUserLeverage
changeCrossMarginLeverage()🔐POSTapi/v2/changeCrossUserLeverage
depositMargin()🔐POSTapi/v1/position/margin/deposit-margin
getCrossMarginRiskLimit()🔐GETapi/v2/batchGetCrossOrderLimit
withdrawMargin()🔐POSTapi/v1/margin/withdrawMargin
getCrossMarginRequirement()🔐GETapi/v2/getCrossModeMarginRequirement
getRiskLimitLevel()🔐GETapi/v1/contracts/risk-limit/{symbol}
updateRiskLimitLevel()🔐POSTapi/v1/position/risk-limit-level/change
getPositionMode()🔐GETapi/v2/position/getPositionMode
updatePositionMode()🔐POSTapi/v2/position/switchPositionMode
getFundingRate()🔐GETapi/v1/funding-rate/{symbol}/current
getFundingRates()🔐GETapi/v1/contract/funding-rates
getFundingHistory()🔐GETapi/v1/funding-history
submitCopyTradeOrder()🔐POSTapi/v1/copy-trade/futures/orders
submitCopyTradeOrderTest()🔐POSTapi/v1/copy-trade/futures/orders/test
submitCopyTradeSLTPOrder()🔐POSTapi/v1/copy-trade/futures/st-orders
cancelCopyTradeOrderById()🔐DELETEapi/v1/copy-trade/futures/orders
cancelCopyTradeOrderByClientOid()🔐DELETEapi/v1/copy-trade/futures/orders/client-order
getCopyTradeMaxOpenSize()🔐GETapi/v1/copy-trade/futures/get-max-open-size
getCopyTradeMaxWithdrawMargin()🔐GETapi/v1/copy-trade/futures/position/margin/max-withdraw-margin
addCopyTradeIsolatedMargin()🔐POSTapi/v1/copy-trade/futures/position/margin/deposit-margin
removeCopyTradeIsolatedMargin()🔐POSTapi/v1/copy-trade/futures/position/margin/withdraw-margin
modifyCopyTradeRiskLimitLevel()🔐POSTapi/v1/copy-trade/futures/position/risk-limit-level/change
updateCopyTradeAutoDepositStatus()🔐POSTapi/v1/copy-trade/futures/position/margin/auto-deposit-status
switchCopyTradeMarginMode()🔐POSTapi/v1/copy-trade/futures/position/changeMarginMode
updateCopyTradeCrossMarginLeverage()🔐POSTapi/v2/copy-trade/futures/changeCrossUserLeverage
getCopyTradeCrossMarginRequirement()🔐POSTapi/v2/copy-trade/getCrossModeMarginRequirement
switchCopyTradePositionMode()🔐POSTapi/v2/copy-trade/position/switchPositionMode
getBrokerRebateOrderDownloadLink()🔐GETapi/v1/broker/api/rebase/download
getBrokerRebateOrderDownloadLinkV2()🔐GETapi/v2/broker/api/rebase/download
getPublicWSConnectionToken()POSTapi/v1/bullet-public
getPrivateWSConnectionToken()🔐POSTapi/v1/bullet-private
getPrivateWSConnectionTokenV2()🔐POSTapi/v2/bullet-private
submitTransferOut()🔐POSTapi/v3/transfer-out
submitTransferIn()🔐POSTapi/v1/transfer-in
getTransfers()🔐GETapi/v1/transfer-list
updateAutoDepositStatus()🔐POSTapi/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.

FunctionAUTHHTTP MethodEndpoint
submitNewSpotOrder()🔐WSspot.order
modifySpotOrder()🔐WSspot.modify
cancelSpotOrder()🔐WSspot.cancel
submitSyncSpotOrder()🔐WSspot.sync_order
cancelSyncSpotOrder()🔐WSspot.sync_cancel
submitMarginOrder()🔐WSmargin.order
cancelMarginOrder()🔐WSmargin.cancel
submitFuturesOrder()🔐WSfutures.order
cancelFuturesOrder()🔐WSfutures.cancel
submitMultipleFuturesOrders()🔐WSfutures.multi_order
cancelMultipleFuturesOrders()🔐WSfutures.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.

FunctionAUTHHTTP MethodEndpoint
getAnnouncements()GETapi/ua/v1/market/announcement
getCurrency()GETapi/ua/v1/market/currency
getThirdPartyCustodyCurrencies()GETapi/ua/v1/oes/currency
getSymbols()GETapi/ua/v1/market/instrument
getTickers()GETapi/ua/v1/market/ticker
getTrades()GETapi/ua/v1/market/trade
getOrderBook()GETapi/ua/v1/market/orderbook
getKlines()GETapi/ua/v1/market/kline
getCurrentFundingRate()GETapi/ua/v1/market/funding-rate
getHistoryFundingRate()GETapi/ua/v1/market/funding-rate-history
getCrossMarginConfig()GETapi/ua/v1/market/cross-config
getBorrowableCurrencies()GETapi/ua/v1/market/borrowable-currency
getServiceStatus()GETapi/ua/v1/server/status
getClassicAccount()🔐GETapi/ua/v1/account/balance
getAccount()🔐GETapi/ua/v1/unified/account/balance
getAccountOverview()🔐GETapi/ua/v1/unified/account/overview
getSubAccount()🔐GETapi/ua/v1/sub-account/balance
getTransferQuotas()🔐GETapi/ua/v1/account/transfer-quota
flexTransfer()🔐POSTapi/ua/v1/account/transfer
setSubAccountTransferPermission()🔐POSTapi/ua/v1/sub-account/canTransferOut
getAccountMode()🔐GETapi/ua/v1/account/mode
setAccountMode()🔐POSTapi/ua/v1/account/mode
getFeeRate()🔐GETapi/ua/v1/user/fee-rate
getAccountLedger()🔐GETapi/ua/v1/account/ledger
getInterestHistory()🔐GETapi/ua/v1/account/interest-history
getBorrowingRatesAndLimits()🔐GETapi/ua/v1/account/interest-limits
modifyLeverage()🔐POSTapi/ua/v1/unified/account/modify-leverage
modifyMarginCrossLeverage()🔐POSTapi/ua/v1/{accountMode}/account/modify-leverage-margin-cross
getLeverage()🔐GETapi/ua/v1/unified/account/leverage
getDepositAddress()🔐GETapi/ua/v1/asset/deposit/address
getThirdPartyCustodyQuota()🔐GETapi/ua/v1/oes/custody-quota
placeOrder()🔐GETapi/ua/v1/{accountMode}/order/detail
batchPlaceOrder()🔐GETapi/ua/v1/{accountMode}/order/detail
getOrderDetails()🔐GETapi/ua/v1/{accountMode}/order/detail
getOpenOrderList()🔐GETapi/ua/v1/{accountMode}/order/open-list
getOrderHistory()🔐GETapi/ua/v1/{accountMode}/order/history
getTradeHistory()🔐GETapi/ua/v1/{accountMode}/order/execution
cancelOrder()🔐POSTapi/ua/v1/unified/order/cancel-all
batchCancelOrders()🔐POSTapi/ua/v1/unified/order/cancel-all
batchCancelOrdersBySymbol()🔐POSTapi/ua/v1/unified/order/cancel-all
setDCP()🔐POSTapi/ua/v1/dcp/set
getDCP()🔐GETapi/ua/v1/dcp/query
getPositionList()🔐GETapi/ua/v1/unified/position/open-list
getPositionsHistory()🔐GETapi/ua/v1/position/history
getPrivateFundingFeeHistory()🔐GETapi/ua/v1/position/funding-history
getAccountPositionTiers()🔐GETapi/ua/v1/{accountMode}/position/tiers

Source: View endpoint map source

KuCoin JavaScript FAQ

What does the KuCoin JavaScript SDK cover?

KuCoin supports Spot, Margin, Futures, Lending, and WebSockets workflows. The JavaScript guide covers the main REST and WebSocket integration patterns.

How do I authenticate private KuCoin API calls in JavaScript?

Install kucoin-api from npm & pass API credentials into the SDK client options, as shown in the KuCoin JavaScript examples above. The SDK handles the exchange-specific signing requirements for private requests.

Does 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.

Where should I start on the KuCoin JavaScript page: REST or WebSocket?

Start with the REST quick start for installation, authentication, and request and response flows. Move to the WebSocket example when you need streaming market or account updates.

Direct Example Files

Open the example files below if you want the clearest general-purpose starting point for REST API, WebSocket, and authentication workflows in plain JavaScript.

Reference Links