KuCoin JavaScript SDK example: rest-futures-private-trade.ts

KuCoin REST futures private trade JavaScript example. Read the source code, review its SDK calls, and browse related exchange integration examples.

This example uses kucoin-api, the JavaScript and TypeScript SDK for KuCoin. Install it with npm install kucoin-api.

We use environment variables in our examples for API keys. It is your responsibility to manage and secure your keys appropriately.

examples/Kucoin/Rest/rest-futures-private-trade.ts

What this example covers

  • KuCoin REST API JavaScript example.
  • Uses the Siebly KuCoin SDK package kucoin-api instead of hand-written HTTP request plumbing.
  • Source path: Kucoin/Rest/rest-futures-private-trade.ts.
  • Imports SDK symbols including FuturesClient.
  • Calls SDK methods such as submitOrder(), generateNewOrderID().

How to use this example

  • Start here for the specific request or stream pattern, then check the matching SDK guide for install, credentials, and operational notes.
  • Open the repository source when you need the latest committed version: GitHub source file.
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 {    /**     * 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.     */     // Submit a futures entry order for 1 lot of XBTUSDTM (0.001 bitcoin)    const orderRes = await client.submitOrder({      clientOid: client.generateNewOrderID(),      side: 'buy',      type: 'market',      symbol: 'XBTUSDTM',      size: 1,      leverage: 2,    });     console.log('orderRes ', JSON.stringify(orderRes, null, 2));  } catch (e) {    console.error('Req error: ', e);  }} start(); 

Subscribe on Substack

Complete the Substack form below to join our newsletter. Substack handles all subscriber data directly.