### Install KuCoin API SDK Source: https://github.com/tiagosiebler/kucoin-api/blob/master/examples/kucoin-SPOT-examples-nodejs.md Instructions for installing the 'kucoin-api' SDK using npm or yarn package managers. ```javascript // Install by npm npm install kucoin-api // Install by yarn yarn add kucoin-api ``` -------------------------------- ### Install KuCoin API SDK via npm and yarn Source: https://github.com/tiagosiebler/kucoin-api/blob/master/examples/kucoin-FUTURES-examples-nodejs.md Install the kucoin-api package using npm or yarn package managers. This is the first step to integrate the KuCoin Futures API into your project. ```bash npm install kucoin-api yarn add kucoin-api ``` -------------------------------- ### Get KuCoin Account Overview and Balances Source: https://github.com/tiagosiebler/kucoin-api/blob/master/examples/kucoin-SPOT-examples-nodejs.md Examples for retrieving account information using the SpotClient. This includes fetching the account summary, all account balances, specific currency balances by type (e.g., main, trade, margin), and account details by ID. It also shows how to access margin-specific balance endpoints. ```javascript // Get Account Summary spotClient.getAccountSummary(); // Get all Account Balances spotClient.getBalances(); // Get specific Account or Currency Balance spotClient.getBalance({ currency: 'USDT', type: 'main', // 'trade' | 'margin' | 'trade_hf' }); // Example call to get account details by ID spotClient.getAccountDetails({ accountId: '5bd6e9286d99522a52e458de' }); // Margin endpoints for balances spotClient.getMarginBalances(); spotClient.getMarginBalance(); spotClient.getIsolatedMarginBalance(); ``` -------------------------------- ### Manage Subaccounts - JavaScript Source: https://github.com/tiagosiebler/kucoin-api/blob/master/examples/kucoin-SPOT-examples-nodejs.md Create and manage subaccounts, query subaccount balances, and handle transfers between master and subaccounts. Includes operations for getting subaccount info, creating new subaccounts, retrieving balances, and submitting transfers. ```javascript // Get all subaccounts spotClient.getSubAccountsV2({}); // Example call to create a sub-account spotClient.createSubAccount({ // Fill in the required parameters for creating a sub-account subName: 'exampleSubAccount', password: 'examplePassword', access: 'trade', }); // Example call to get sub-account balance with specified parameters spotClient.getSubAccountBalance({ subUserId: '5caefba7d9575a0688f83c45', includeBaseAmount: false, }); // Example call to get sub-account balances spotClient.getSubAccountBalancesV2(); // Example call to get transferable funds spotClient.getTransferable({ currency: 'BTC', type: 'MAIN', }); // Example call to submit a transfer from master to sub-account spotClient.submitTransferMasterSub({ clientOid: client.generateNewOrderID(), // or use your custom UUID amount: 0.01, currency: 'USDT', direction: 'OUT', // 'IN' for transfer to master, 'OUT' for transfer to sub subUserId: 'enter_sub_user_id_here', }); // Example call to submit an inner transfer within same account spotClient.submitInnerTransfer({ clientOid: client.generateNewOrderID(), // or use your custom UUID amount: 0.01, currency: 'USDT', from: 'main', // Source account type to: 'trade', // Destination account type }); ``` -------------------------------- ### Fetch Positions Source: https://github.com/tiagosiebler/kucoin-api/blob/master/examples/kucoin-FUTURES-examples-nodejs.md Retrieves details about open and historical trading positions. You can get details for a specific symbol, a list of positions for a currency, or all positions. Historical positions can also be fetched. ```javascript // Get Position Details futuresClient.getPosition({ symbol: 'ETHUSDTM' }); // Get Position List futuresClient.getPositions({ currency: 'USDT' }); // Or Search All futuresClient.getPositions(); // Get History Positions futuresClient.getHistoryPositions({ symbol: 'ETHUSDTM' }); ``` -------------------------------- ### Get Account Transactions - JavaScript Source: https://github.com/tiagosiebler/kucoin-api/blob/master/examples/kucoin-SPOT-examples-nodejs.md Retrieve account ledger entries for specified currency and time range. Supports standard, high-frequency, and margin transaction queries. Returns transaction history filtered by business type and currency parameters. ```javascript // Example call to get account ledgers with specified parameters spotClient.getTransactions({ currency: 'BTC', startAt: 1601395200000 }); // Example call to get high-frequency account ledgers with specified parameters spotClient.getHFTransactions({ bizType: 'TRADE_EXCHANGE', currency: 'YOP,DAI', startAt: 1601395200000, }); // Example call to get high-frequency margin account ledgers with specified parameters spotClient.getHFMarginTransactions({ bizType: 'MARGIN_EXCHANGE', currency: 'YOP,DAI', startAt: 1601395200000, }); ``` -------------------------------- ### GET /api/v1/broker/api/rebase/download Source: https://github.com/tiagosiebler/kucoin-api/blob/master/docs/endpointFunctionList.md Get the broker rebate order download link (v1). This endpoint provides a URL to download rebate order records in v1 format. ```APIDOC ## GET /api/v1/broker/api/rebase/download ### Description Get the broker rebate order download link (v1 format). ### Method GET ### Endpoint `api/v1/broker/api/rebase/download` ### Authentication Required (API Key) ### Parameters #### Query Parameters - **startDate** (string) - Optional - Start date for rebate records (YYYY-MM-DD) - **endDate** (string) - Optional - End date for rebate records (YYYY-MM-DD) ### Response #### Success Response (200) - **downloadUrl** (string) - URL to download rebate order file - **expiresAt** (number) - URL expiration timestamp #### Response Example { "downloadUrl": "https://example.com/download/rebate_orders_v1.csv", "expiresAt": 1699999999 } ``` -------------------------------- ### Place Market Sell Order (Short) Source: https://github.com/tiagosiebler/kucoin-api/blob/master/examples/kucoin-FUTURES-examples-nodejs.md Execute a market sell order (short position) on KuCoin Futures. This example places an order for a specified size of a contract with a given leverage. Requires a futures client and order details. ```javascript // A MARKET SHORT of 2 contracts of XBT using leverage of 5: const marketShort = futureTransfers.submitOrder({ clientOid: '123456789', leverage: '5', side: 'sell', size: 2, symbol: 'XBTUSDTM', timeInForce: 'GTC', type: 'market', }); ``` -------------------------------- ### Place Limit Sell Order (Short) Source: https://github.com/tiagosiebler/kucoin-api/blob/master/examples/kucoin-FUTURES-examples-nodejs.md Execute a limit sell order (short position) on KuCoin Futures. This example places an order to sell at a specific price for a given size and leverage. Requires a futures client and detailed order parameters. ```javascript // A LIMIT SHORT of 2 contracts of XBT using leverage of 5: const limitShort = futureTransfers.submitOrder({ clientOid: '123456789', leverage: '5', price: '70300.31', side: 'sell', size: 2, symbol: 'XBTUSDTM', timeInForce: 'GTC', type: 'limit', }); ``` -------------------------------- ### GET /api/v2/broker/api/rebase/download Source: https://github.com/tiagosiebler/kucoin-api/blob/master/docs/endpointFunctionList.md Get the broker rebate order download link (v2). This endpoint provides a URL to download rebate order records in v2 format with enhanced features. ```APIDOC ## GET /api/v2/broker/api/rebase/download ### Description Get the broker rebate order download link (v2 format). ### Method GET ### Endpoint `api/v2/broker/api/rebase/download` ### Authentication Required (API Key) ### Parameters #### Query Parameters - **startDate** (string) - Optional - Start date for rebate records (YYYY-MM-DD) - **endDate** (string) - Optional - End date for rebate records (YYYY-MM-DD) ### Response #### Success Response (200) - **downloadUrl** (string) - URL to download rebate order file - **expiresAt** (number) - URL expiration timestamp #### Response Example { "downloadUrl": "https://example.com/download/rebate_orders_v2.csv", "expiresAt": 1699999999 } ``` -------------------------------- ### Place Market Buy Order (Long) Source: https://github.com/tiagosiebler/kucoin-api/blob/master/examples/kucoin-FUTURES-examples-nodejs.md Execute a market buy order (long position) on KuCoin Futures. This example places an order for a specified size of a contract with a given leverage. Requires a futures client and order details. ```javascript // A MARKET LONG of 2 contracts of XBT using leverage of 5: const marketLong = futureTransfers.submitOrder({ clientOid: '123456789', leverage: '5', side: 'buy', size: 2, symbol: 'XBTUSDTM', timeInForce: 'GTC', type: 'market', }); ``` -------------------------------- ### Initialize KuCoin SpotClient Source: https://github.com/tiagosiebler/kucoin-api/blob/master/examples/kucoin-SPOT-examples-nodejs.md Demonstrates how to import and initialize the SpotClient from the 'kucoin-api' SDK in Node.js or JavaScript projects. Requires API key, secret, and passphrase for authentication, which can be securely managed using environment variables. ```javascript // require const { SpotClient } = require('kucoin-api'); // import import { SpotClient } from 'kucoin-api'; // initialise Spot Client const spotClient = new SpotClient({ // insert your api key, secret and passphrase - use env vars, if not just fill the string values apiKey: process.env.KUCOIN_API_KEY || 'insert-your-api-key', apiSecret: process.env.KUCOIN_API_SECRET || 'insert-your-api-secret', apiPassphrase: process.env.KUCOIN_API_PASSPHRASE || 'insert-your-api-passphrase', }); ``` -------------------------------- ### Submit Market Short Order - JavaScript Source: https://github.com/tiagosiebler/kucoin-api/blob/master/examples/kucoin-SPOT-examples-nodejs.md Place a market short sell order for spot trading. Executes an immediate sell at current market price with specified quantity and symbol. Requires unique clientOid for order tracking. ```javascript // Market short order const marketShort = spotClient.submitOrder({ clientOid: client.generateNewOrderID(), // or use your custom UUID side: 'sell', symbol: 'ETH-BTC', type: 'market', size: '0.5', // Specify the quantity to sell }); ``` -------------------------------- ### GET /api/v1/transfer-list Source: https://github.com/tiagosiebler/kucoin-api/blob/master/docs/endpointFunctionList.md Get the list of account transfers. This endpoint retrieves the history of all transfer in and transfer out transactions for the futures account. ```APIDOC ## GET /api/v1/transfer-list ### Description Get the list of account transfers for futures account. ### Method GET ### Endpoint `api/v1/transfer-list` ### Authentication Required (API Key) ### Parameters #### Query Parameters - **currency** (string) - Optional - Filter by currency - **status** (string) - Optional - Filter by status (pending, completed, failed) - **pageNum** (number) - Optional - Page number (default: 1) - **pageSize** (number) - Optional - Page size (default: 10, max: 100) ### Response #### Success Response (200) - **transferList** (array) - Array of transfers - **transferId** (string) - Transfer identifier - **currency** (string) - Currency transferred - **amount** (number) - Transfer amount - **status** (string) - Transfer status - **direction** (string) - Transfer direction (in or out) - **timestamp** (number) - Transfer timestamp #### Response Example { "transferList": [ { "transferId": "transfer_123456", "currency": "USDT", "amount": 1000, "status": "completed", "direction": "in", "timestamp": 1699999999000 } ] } ``` -------------------------------- ### Manage Deposits and Withdrawals - JavaScript Source: https://github.com/tiagosiebler/kucoin-api/blob/master/examples/kucoin-SPOT-examples-nodejs.md Create deposit addresses, retrieve deposit/withdrawal history, and submit withdrawal requests. Supports address creation with optional chain specification, deposit listing, withdrawal submission with memo, and withdrawal cancellation by ID. ```javascript // Example call to create a deposit address spotClient.createDepositAddress({ currency: 'BTC', // Optional parameter chain: 'BTC', }); // Example call to get deposit addresses with specified parameters spotClient.getDepositAddressesV2({ currency: 'BTC', }); // Example call to get deposits spotClient.getDeposits(); // Example call to get withdrawals with specified parameters spotClient.getWithdrawals({ currency: 'BTC', // Optional parameter }); // Example call to submit a withdrawal spotClient.submitWithdraw({ currency: 'BTC', address: '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa', amount: 0.01, // Optional parameters memo: 'exampleMemo', chain: 'BTC', }); // Example call to cancel a withdrawal by ID spotClient.cancelWithdrawal({ withdrawalId: '5bffb63303aa675e8bbe18f9', }); ``` -------------------------------- ### Initialize and Use SpotClient for Spot Market Trading (JavaScript) Source: https://context7.com/tiagosiebler/kucoin-api/llms.txt Demonstrates how to initialize the SpotClient with API credentials and perform common spot trading operations like getting balances, submitting orders, and cancelling orders. It requires API key, secret, and passphrase for authentication. Handles potential errors during API calls. ```javascript const { SpotClient } = require('kucoin-api'); const client = new SpotClient({ apiKey: 'your-api-key', apiSecret: 'your-api-secret', apiPassphrase: 'your-api-passphrase', // NOT your account password }); async function spotTradingExample() { try { // Get account balance const balance = await client.getBalances(); console.log('Account balances:', balance); // Get market ticker const ticker = await client.getTicker({ symbol: 'BTC-USDT' }); console.log('BTC-USDT ticker:', ticker); // Submit high-frequency (HF) spot order const buyOrder = await client.submitHFOrder({ clientOid: client.generateNewOrderID(), side: 'buy', type: 'limit', symbol: 'BTC-USDT', price: '20000', size: '0.001', }); console.log('Buy order submitted:', buyOrder); // Get order by ID const orderDetails = await client.getHFOrderByOrderId({ symbol: 'BTC-USDT', orderId: buyOrder.data.orderId, }); console.log('Order details:', orderDetails); // Cancel order const cancelResult = await client.cancelHFOrderByOrderId({ symbol: 'BTC-USDT', orderId: buyOrder.data.orderId, }); console.log('Order cancelled:', cancelResult); } catch (error) { console.error('Error:', error.response?.data || error.message); } } spotTradingExample(); ``` -------------------------------- ### GET /api/v1/hf/orders/active/symbols Source: https://github.com/tiagosiebler/kucoin-api/blob/master/docs/endpointFunctionList.md Get a list of trading symbols that have active high-frequency orders. This endpoint returns all symbols with currently open HF orders. ```APIDOC ## GET /api/v1/hf/orders/active/symbols ### Description Get a list of trading symbols that have active high-frequency orders. ### Method GET ### Endpoint api/v1/hf/orders/active/symbols ### Authentication Requires API key authentication (private endpoint) ### Response #### Success Response (200) - **symbols** (array) - List of trading symbols with active orders ``` -------------------------------- ### GET /api/ua/v1/market/currency - Get Currency Information Source: https://github.com/tiagosiebler/kucoin-api/blob/master/docs/endpointFunctionList.md Retrieve supported currencies and their information from the KuCoin unified API. This public endpoint provides currency details and specifications. ```APIDOC ## GET /api/ua/v1/market/currency ### Description Retrieve supported currencies and their information from KuCoin. ### Method GET ### Endpoint `api/ua/v1/market/currency` ### Authentication Not required - Public endpoint ### Function `getCurrency()` ### Response - Supported currencies with their specifications and details ### Notes - Public endpoint accessible without authentication - See [UnifiedAPIClient.ts source](https://github.com/tiagosiebler/kucoin-api/blob/master/src/UnifiedAPIClient.ts#L76) ``` -------------------------------- ### Manage Subaccount API Keys - JavaScript Source: https://github.com/tiagosiebler/kucoin-api/blob/master/examples/kucoin-SPOT-examples-nodejs.md Create, retrieve, update, and delete API keys for subaccounts. Enables programmatic management of subaccount API credentials including passphrase and remark information. ```javascript // Get all subaccount APIs spotClient.getSubAPIs({ subName: 'my_sub_name', }); // Create APIs for Sub-Account spotClient.createSubAPI({ subName: 'my_sub_name', passphrase: 'my_passphrase', remark: 'my_remark', }); // Modify Sub-Account APIs spotClient.updateSubAPI({ subName: 'my_sub_name', passphrase: 'my_passphrase', apiKey: 'my_api_key', }); // Delete Sub-Account APIs spotClient.deleteSubAPI({ subName: 'my_sub_name', passphrase: 'my_passphrase', apiKey: 'my_api_key', }); ``` -------------------------------- ### GET /api/ua/v1/market/announcement - Get Announcements Source: https://github.com/tiagosiebler/kucoin-api/blob/master/docs/endpointFunctionList.md Retrieve market announcements from the KuCoin unified API. This public endpoint provides access to current market announcements and notices. ```APIDOC ## GET /api/ua/v1/market/announcement ### Description Retrieve market announcements from KuCoin. ### Method GET ### Endpoint `api/ua/v1/market/announcement` ### Authentication Not required - Public endpoint ### Function `getAnnouncements()` ### Response - Market announcements and notices ### Notes - Public endpoint accessible without authentication - See [UnifiedAPIClient.ts source](https://github.com/tiagosiebler/kucoin-api/blob/master/src/UnifiedAPIClient.ts#L66) ``` -------------------------------- ### Place Multiple Limit Orders Source: https://github.com/tiagosiebler/kucoin-api/blob/master/examples/kucoin-SPOT-examples-nodejs.md Submits multiple limit orders for a specified symbol simultaneously. Requires a `spotClient` instance and an array of order objects, each with `clientOid`, `side`, `type`, `price`, and `size`. This is useful for efficiently placing several orders at once. ```javascript const multipleOrders = [ { clientOid: '3d07008668054da6b3cb12e432c2b13a', side: 'buy', type: 'limit', price: '0.01', size: '0.01', }, { clientOid: '37245dbe6e134b5c97732bfb36cd4a9d', side: 'buy', type: 'limit', price: '0.01', size: '0.01', }, ]; spotClient.submitMultipleOrders({ symbol: 'KCS-USDT', orderList: multipleOrders, }); ``` -------------------------------- ### Query Currencies and Symbols - JavaScript Source: https://github.com/tiagosiebler/kucoin-api/blob/master/examples/kucoin-SPOT-examples-nodejs.md Retrieve comprehensive market data including all available currencies, specific currency information, trading symbols, and ticker data. Supports fetching individual ticker, all tickers, and 24-hour statistics for symbols. ```javascript // Get All Currencies List spotClient.getCurrencies(); // Get info for a specific currency spotClient.getCurrency({ currency: 'BTC', }); // Get all Symbols spotClient.getSymbols(); // Example call to get ticker information for a specific symbol spotClient.getTicker({ symbol: 'BTC-USDT', }); // All tickers spotClient.getTickers(); // Get 24h stats for a specific symbol spotClient.get24hrStats({ symbol: 'BTC-USDT', }); ``` -------------------------------- ### GET /api/v1/copy-trade/futures/position/margin/max-withdraw-margin Source: https://github.com/tiagosiebler/kucoin-api/blob/master/docs/endpointFunctionList.md Get the maximum margin that can be withdrawn from a copy trade futures position. This endpoint calculates safe withdrawal limits based on current position requirements. ```APIDOC ## GET /api/v1/copy-trade/futures/position/margin/max-withdraw-margin ### Description Retrieve the maximum margin that can be safely withdrawn from a copy trade futures position. ### Method GET ### Endpoint `api/v1/copy-trade/futures/position/margin/max-withdraw-margin` ### Authentication Required (API Key) ### Parameters #### Query Parameters - **symbol** (string) - Required - Trading pair symbol ### Response #### Success Response (200) - **maxWithdrawMargin** (number) - Maximum margin available to withdraw - **symbol** (string) - Trading pair symbol - **currentMargin** (number) - Current margin allocated #### Response Example { "maxWithdrawMargin": 500, "symbol": "BTC/USDT", "currentMargin": 1000 } ``` -------------------------------- ### Fetch Orders Source: https://github.com/tiagosiebler/kucoin-api/blob/master/examples/kucoin-SPOT-examples-nodejs.md Retrieves order information from the KuCoin API using a `spotClient` instance. Supports fetching open orders by status ('active'), closed orders ('done'), recent orders completed in the last 24 hours, and details of a single order by its client order ID or order ID. ```javascript // Get open orders spotClient.getOrders({ status: 'active' }); // Get closed orders spotClient.getOrders({ status: 'done' }); // Get List of Orders Completed in 24h spotClient.getRecentOrders(); // Get Details of a Single Order by ClientOrderId spotClient.getOrderByClientOid({ clientOid: 'clientOid' }); // Or By OrderId spotClient.getOrderByOrderId({ orderId: 'orderId' }); ``` -------------------------------- ### GET /api/ua/v1/server/status - Get Service Status Source: https://github.com/tiagosiebler/kucoin-api/blob/master/docs/endpointFunctionList.md Retrieve the current service status from the KuCoin unified API. This public endpoint provides information about KuCoin service availability and status. ```APIDOC ## GET /api/ua/v1/server/status ### Description Retrieve the current service status from KuCoin. ### Method GET ### Endpoint `api/ua/v1/server/status` ### Authentication Not required - Public endpoint ### Function `getServiceStatus()` ### Response - Service status information including availability and operational status ### Notes - Public endpoint accessible without authentication - Provides real-time service status updates - See [UnifiedAPIClient.ts source](https://github.com/tiagosiebler/kucoin-api/blob/master/src/UnifiedAPIClient.ts#L166) ``` -------------------------------- ### Fetch Market Data - Public Trades and Index Source: https://github.com/tiagosiebler/kucoin-api/blob/master/examples/kucoin-FUTURES-examples-nodejs.md Retrieve public trade data, interest rates, index information, mark prices, premium index data, and 24-hour transaction volumes from the KuCoin Futures API. Requires a futures client instance. ```javascript // Get Public Trades uturesClient.getMarketTrades({ symbol: 'XBTUSDTM' }); // Get Interest Rate List uturesClient.getInterestRates({ symbol: '.XBTINT' }); // Get Index List uturesClient.getIndex({ symbol: '.KXBT' }); // Get Current Mark Price uturesClient.getMarkPrice({ symbol: 'XBTUSDM' }); // Get Premium Index uturesClient.getPremiumIndex({ symbol: '.XBTUSDMPI' }); // Get 24hour futures transaction volume uturesClient.get24HourTransactionVolume(); ``` -------------------------------- ### GET /api/ua/v1/market/orderbook - Get Order Book Source: https://github.com/tiagosiebler/kucoin-api/blob/master/docs/endpointFunctionList.md Retrieve the order book (bid/ask levels) from the KuCoin unified API. This public endpoint provides real-time market depth information. ```APIDOC ## GET /api/ua/v1/market/orderbook ### Description Retrieve the order book (bid/ask levels) from KuCoin market. ### Method GET ### Endpoint `api/ua/v1/market/orderbook` ### Authentication Not required - Public endpoint ### Function `getOrderBook()` ### Response - Order book data with bid and ask levels, quantities, and prices ### Notes - Public endpoint accessible without authentication - Provides real-time market depth - See [UnifiedAPIClient.ts source](https://github.com/tiagosiebler/kucoin-api/blob/master/src/UnifiedAPIClient.ts#L116) ``` -------------------------------- ### GET /api/ua/v1/market/trade - Get Recent Trades Source: https://github.com/tiagosiebler/kucoin-api/blob/master/docs/endpointFunctionList.md Retrieve recent trade history from the KuCoin unified API. This public endpoint provides information about recently executed trades on the market. ```APIDOC ## GET /api/ua/v1/market/trade ### Description Retrieve recent trade history from KuCoin market. ### Method GET ### Endpoint `api/ua/v1/market/trade` ### Authentication Not required - Public endpoint ### Function `getTrades()` ### Response - Recent trade data including price, volume, and timestamps ### Notes - Public endpoint accessible without authentication - Provides real-time trade information - See [UnifiedAPIClient.ts source](https://github.com/tiagosiebler/kucoin-api/blob/master/src/UnifiedAPIClient.ts#L106) ``` -------------------------------- ### Import and Initialize FuturesClient in JavaScript/TypeScript Source: https://github.com/tiagosiebler/kucoin-api/blob/master/examples/kucoin-FUTURES-examples-nodejs.md Import the FuturesClient class and initialize it with API credentials (key, secret, passphrase). Supports both CommonJS require and ES6 import syntax. API credentials should be stored in environment variables for security. ```javascript // require const { FuturesClient } = require('kucoin-api'); // import import { FuturesClient } from 'kucoin-api'; // initialise Futures Client const futuresClient = new FuturesClient({ // insert your api key, secret and passphrase - use env vars, if not just fill the string values apiKey: process.env.KUCOIN_API_KEY || 'insert-your-api-key', apiSecret: process.env.KUCOIN_API_SECRET || 'insert-your-api-secret', apiPassphrase: process.env.KUCOIN_API_PASSPHRASE || 'insert-your-api-passphrase', }); ``` -------------------------------- ### GET /api/ua/v1/market/instrument - Get Trading Symbols Source: https://github.com/tiagosiebler/kucoin-api/blob/master/docs/endpointFunctionList.md Retrieve trading symbols and instrument information from the KuCoin unified API. This public endpoint provides details about available trading pairs. ```APIDOC ## GET /api/ua/v1/market/instrument ### Description Retrieve trading symbols and instrument information from KuCoin. ### Method GET ### Endpoint `api/ua/v1/market/instrument` ### Authentication Not required - Public endpoint ### Function `getSymbols()` ### Response - Trading symbols and instrument specifications ### Notes - Public endpoint accessible without authentication - See [UnifiedAPIClient.ts source](https://github.com/tiagosiebler/kucoin-api/blob/master/src/UnifiedAPIClient.ts#L86) ``` -------------------------------- ### KuCoin WebSocket API Client (TypeScript) Source: https://github.com/tiagosiebler/kucoin-api/blob/master/README.md Demonstrates how to use the WebsocketAPIClient for making REST-like calls to the KuCoin WebSocket API. It shows examples of submitting spot and futures orders, including configuration for API keys and optional custom logging. ```typescript import { DefaultLogger, WebsocketAPIClient } from 'kucoin-api'; const customLogger = { ...DefaultLogger, // 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', }; const wsClient = new WebsocketAPIClient({ apiKey: account.key, apiSecret: account.secret, apiPassphrase: account.passphrase, // attachEventListeners: false }, // customLogger, // optional: uncomment this to inject a custom logger ); wsClient .submitNewSpotOrder({ side: 'buy', symbol: 'BTC-USDT', type: 'limit', price: '150000', size: '0.0001', }) .then((syncSpotOrderResponse) => { console.log('Sync spot order response:', syncSpotOrderResponse); }) .catch((e) => { console.log('Sync spot order error:', e); }); wsClient .submitFuturesOrder({ clientOid: 'futures-test-' + Date.now(), side: 'buy', symbol: 'XBTUSDTM', marginMode: 'CROSS', type: 'limit', price: '1000', qty: '0.01', leverage: 10, positionSide: 'LONG', // needed if trading two-way (hedge) position mode }) .then((futuresOrderResponse) => { console.log('Futures order response:', futuresOrderResponse); }) .catch((e) => { console.log('Futures order error:', e); }); ``` -------------------------------- ### GET /api/ua/v1/market/cross-config - Get Cross Margin Configuration Source: https://github.com/tiagosiebler/kucoin-api/blob/master/docs/endpointFunctionList.md Retrieve cross margin configuration from the KuCoin unified API. This public endpoint provides information about cross margin trading settings and requirements. ```APIDOC ## GET /api/ua/v1/market/cross-config ### Description Retrieve cross margin configuration from KuCoin. ### Method GET ### Endpoint `api/ua/v1/market/cross-config` ### Authentication Not required - Public endpoint ### Function `getCrossMarginConfig()` ### Response - Cross margin configuration including risk limits and requirements ### Notes - Public endpoint accessible without authentication - Provides configuration for cross margin trading - See [UnifiedAPIClient.ts source](https://github.com/tiagosiebler/kucoin-api/blob/master/src/UnifiedAPIClient.ts#L156) ``` -------------------------------- ### Earn and Structured Product APIs Source: https://github.com/tiagosiebler/kucoin-api/blob/master/docs/endpointFunctionList.md APIs for subscribing to earn products, managing redemptions, and retrieving product information. ```APIDOC ## POST /api/v1/earn/orders ### Description Subscribes to an earn fixed income product. ### Method POST ### Endpoint `/api/v1/earn/orders` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body Requires specific parameters to define the subscription, such as product ID and amount. ### Request Example ```json { "productId": "some_product_id", "amount": 100 } ``` ### Response #### Success Response (200) Confirmation of subscription. #### Response Example ```json { "code": "200000", "data": "Subscription successful" } ``` ## GET /api/v1/earn/redeem-preview ### Description Retrieves a preview of an earn redemption. ### Method GET ### Endpoint `/api/v1/earn/redeem-preview` ### Parameters #### Path Parameters None #### Query Parameters Requires parameters like `orderId` and `redeemType`. ### Request Example ``` /api/v1/earn/redeem-preview?orderId=123&redeemType=FULL ``` ### Response #### Success Response (200) Details of the redemption preview. #### Response Example ```json { "code": "200000", "data": { "estimatedAmount": 99.5 } } ``` ## DELETE /api/v1/earn/orders ### Description Submits a redemption request for an earn order. ### Method DELETE ### Endpoint `/api/v1/earn/orders` ### Parameters #### Path Parameters None #### Query Parameters Requires `orderId` and `redeemType`. ### Request Example ``` /api/v1/earn/orders?orderId=123&redeemType=PARTIAL&amount=10 ``` ### Response #### Success Response (200) Confirmation of redemption submission. #### Response Example ```json { "code": "200000", "data": "Redemption submitted successfully" } ``` ## GET /api/v1/earn/saving/products ### Description Retrieves a list of available earn saving products. ### Method GET ### Endpoint `/api/v1/earn/saving/products` ### Parameters None ### Response #### Success Response (200) List of saving products. #### Response Example ```json { "code": "200000", "data": [ { "productId": "SAVING001", "name": "USD Saving Account", "apy": "2.5%" } ] } ``` ## GET /api/v1/earn/promotion/products ### Description Retrieves a list of available earn promotion products. ### Method GET ### Endpoint `/api/v1/earn/promotion/products` ### Parameters None ### Response #### Success Response (200) List of promotion products. #### Response Example ```json { "code": "200000", "data": [ { "productId": "PROMO001", "name": "Limited Time Offer", "apy": "5.0%" } ] } ``` ## GET /api/v1/earn/hold-assets ### Description Retrieves assets currently held in earn products. ### Method GET ### Endpoint `/api/v1/earn/hold-assets` ### Parameters None ### Response #### Success Response (200) List of held assets. #### Response Example ```json { "code": "200000", "data": [ { "asset": "USDT", "amount": 500 } ] } ``` ## GET /api/v1/earn/staking/products ### Description Retrieves a list of available earn staking products. ### Method GET ### Endpoint `/api/v1/earn/staking/products` ### Parameters None ### Response #### Success Response (200) List of staking products. #### Response Example ```json { "code": "200000", "data": [ { "productId": "STAKING001", "name": "ETH 2.0 Staking", "apy": "4.0%" } ] } ``` ## GET /api/v1/earn/kcs-staking/products ### Description Retrieves a list of available KCS staking products for earn. ### Method GET ### Endpoint `/api/v1/earn/kcs-staking/products` ### Parameters None ### Response #### Success Response (200) List of KCS staking products. #### Response Example ```json { "code": "200000", "data": [ { "productId": "KCSSTAKING001", "name": "KCS Staking", "apy": "3.0%" } ] } ``` ## GET /api/v1/earn/eth-staking/products ### Description Retrieves a list of available ETH staking products for earn. ### Method GET ### Endpoint `/api/v1/earn/eth-staking/products` ### Parameters None ### Response #### Success Response (200) List of ETH staking products. #### Response Example ```json { "code": "200000", "data": [ { "productId": "ETHSTAKING001", "name": "ETH Staking", "apy": "3.5%" } ] } ``` ## POST /api/v1/struct-earn/orders ### Description Submits a purchase order for a structured earn product. ### Method POST ### Endpoint `/api/v1/struct-earn/orders` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body Requires product details, amount, and other relevant parameters for structured products. ### Request Example ```json { "productId": "STRUCT001", "amount": 200, "targetPrice": 3000 } ``` ### Response #### Success Response (200) Confirmation of structured product purchase. #### Response Example ```json { "code": "200000", "data": "Purchase successful" } ``` ## GET /api/v1/struct-earn/dual/products ### Description Retrieves a list of available dual investment products. ### Method GET ### Endpoint `/api/v1/struct-earn/dual/products` ### Parameters None ### Response #### Success Response (200) List of dual investment products. #### Response Example ```json { "code": "200000", "data": [ { "productId": "DUAL001", "name": "BTC Dual Investment", "yieldRate": "4.5%" } ] } ``` ## GET /api/v1/struct-earn/orders ### Description Retrieves a list of structured earn product orders. ### Method GET ### Endpoint `/api/v1/struct-earn/orders` ### Parameters #### Path Parameters None #### Query Parameters Optional parameters like `status` or `productId` can be used for filtering. ### Request Example ``` /api/v1/struct-earn/orders?status=ACTIVE ``` ### Response #### Success Response (200) List of structured earn orders. #### Response Example ```json { "code": "200000", "data": [ { "orderId": "STRUCTORDER001", "productId": "DUAL001", "status": "ACTIVE" } ] } ``` ``` -------------------------------- ### Fetch Fills Source: https://github.com/tiagosiebler/kucoin-api/blob/master/examples/kucoin-SPOT-examples-nodejs.md Retrieves trade execution data (fills) using the `spotClient`. You can fetch specific fills by type (e.g., 'market') or retrieve all fills. It also allows fetching recent fills from the last 24 hours. ```javascript // Get Specific Fills spotClient.getFills({ type: 'market' }); // or search for all spotClient.getFills(); // Recent Fills from last 24 hours spotClient.getRecentFills(); ``` -------------------------------- ### GET /api/ua/v1/market/funding-rate - Get Current Funding Rate Source: https://github.com/tiagosiebler/kucoin-api/blob/master/docs/endpointFunctionList.md Retrieve the current funding rate for futures contracts from the KuCoin unified API. This public endpoint provides real-time funding rate information. ```APIDOC ## GET /api/ua/v1/market/funding-rate ### Description Retrieve the current funding rate for futures contracts from KuCoin. ### Method GET ### Endpoint `api/ua/v1/market/funding-rate` ### Authentication Not required - Public endpoint ### Function `getCurrentFundingRate()` ### Response - Current funding rate for perpetual futures contracts ### Notes - Public endpoint accessible without authentication - Provides real-time funding rate data for futures traders - See [UnifiedAPIClient.ts source](https://github.com/tiagosiebler/kucoin-api/blob/master/src/UnifiedAPIClient.ts#L136) ``` -------------------------------- ### Retrieve Order Book Data - JavaScript Source: https://github.com/tiagosiebler/kucoin-api/blob/master/examples/kucoin-SPOT-examples-nodejs.md Fetch order book data at different depth levels (20, 100, or full orderbook). Returns bid/ask price levels and quantities for specified trading symbol. ```javascript // get partial orderbook spotClient.getOrderBookLevel20({ symbol: 'BTC-USDT' }); // get partial orderbook spotClient.getOrderBookLevel100({ symbol: 'BTC-USDT' }); // get full orderbook spotClient.getFullOrderBook({ symbol: 'BTC-USDT' }); ``` -------------------------------- ### GET /api/ua/v1/market/ticker - Get Market Tickers Source: https://github.com/tiagosiebler/kucoin-api/blob/master/docs/endpointFunctionList.md Retrieve current market ticker data from the KuCoin unified API. This public endpoint provides real-time price and volume information for trading pairs. ```APIDOC ## GET /api/ua/v1/market/ticker ### Description Retrieve current market ticker data from KuCoin. ### Method GET ### Endpoint `api/ua/v1/market/ticker` ### Authentication Not required - Public endpoint ### Function `getTickers()` ### Response - Current ticker data including price, volume, and market information ### Notes - Public endpoint accessible without authentication - Provides real-time market data - See [UnifiedAPIClient.ts source](https://github.com/tiagosiebler/kucoin-api/blob/master/src/UnifiedAPIClient.ts#L96) ``` -------------------------------- ### Broker APIs Source: https://github.com/tiagosiebler/kucoin-api/blob/master/docs/endpointFunctionList.md APIs for brokers to access rebate order download links. ```APIDOC ## GET /api/v1/broker/api/rebase/download ### Description Retrieves a download link for broker rebate orders (v1). ### Method GET ### Endpoint `/api/v1/broker/api/rebase/download` ### Parameters None ### Response #### Success Response (200) Download link for rebate orders. #### Response Example ```json { "code": "200000", "data": { "url": "https://example.com/rebate_orders_v1.csv" } } ``` ## GET /api/v2/broker/api/rebase/download ### Description Retrieves a download link for broker rebate orders (v2). ### Method GET ### Endpoint `/api/v2/broker/api/rebase/download` ### Parameters None ### Response #### Success Response (200) Download link for rebate orders. #### Response Example ```json { "code": "200000", "data": { "url": "https://example.com/rebate_orders_v2.csv" } } ``` ``` -------------------------------- ### GET /api/ua/v1/market/funding-rate-history - Get Historical Funding Rates Source: https://github.com/tiagosiebler/kucoin-api/blob/master/docs/endpointFunctionList.md Retrieve historical funding rate data for futures contracts from the KuCoin unified API. This public endpoint provides past funding rate information. ```APIDOC ## GET /api/ua/v1/market/funding-rate-history ### Description Retrieve historical funding rate data for futures contracts from KuCoin. ### Method GET ### Endpoint `api/ua/v1/market/funding-rate-history` ### Authentication Not required - Public endpoint ### Function `getHistoryFundingRate()` ### Response - Historical funding rate data for perpetual futures contracts ### Notes - Public endpoint accessible without authentication - Provides historical funding rate data for analysis - See [UnifiedAPIClient.ts source](https://github.com/tiagosiebler/kucoin-api/blob/master/src/UnifiedAPIClient.ts#L146) ``` -------------------------------- ### GET /api/ua/v1/market/kline - Get Candlestick Data Source: https://github.com/tiagosiebler/kucoin-api/blob/master/docs/endpointFunctionList.md Retrieve candlestick (kline) data from the KuCoin unified API. This public endpoint provides OHLCV (Open, High, Low, Close, Volume) data for technical analysis. ```APIDOC ## GET /api/ua/v1/market/kline ### Description Retrieve candlestick (kline) data from KuCoin market. ### Method GET ### Endpoint `api/ua/v1/market/kline` ### Authentication Not required - Public endpoint ### Function `getKlines()` ### Response - Candlestick data with OHLCV information at various time intervals ### Notes - Public endpoint accessible without authentication - Provides historical price data for technical analysis - See [UnifiedAPIClient.ts source](https://github.com/tiagosiebler/kucoin-api/blob/master/src/UnifiedAPIClient.ts#L126) ``` -------------------------------- ### Place Limit Short Order Source: https://github.com/tiagosiebler/kucoin-api/blob/master/examples/kucoin-SPOT-examples-nodejs.md Submits a limit order to sell a specified quantity of a trading pair at a specific price. Requires a `spotClient` instance, `client.generateNewOrderID()`, and defines `price`, `size`, and `timeInForce`. The order will only execute when the market price reaches the specified sell price. ```javascript const limitShort = spotClient.submitOrder({ clientOid: client.generateNewOrderID(), // or use your custom UUID side: 'sell', symbol: 'ETH-BTC', type: 'limit', price: '0.03', // Specify the price to sell size: '0.5', // Specify the quantity to sell timeInForce: 'GTC', // Good Till Canceled }); ``` -------------------------------- ### Submit Multiple Orders Source: https://github.com/tiagosiebler/kucoin-api/blob/master/examples/kucoin-FUTURES-examples-nodejs.md Submits an array of order objects to be executed simultaneously. Each order object must contain clientOid, side, symbol, type, price, leverage, and size. ```javascript //request const orders = [ { clientOid: '5c52e11203aa677f33e491', side: 'buy', symbol: 'ETHUSDTM', type: 'limit', price: '2150', leverage: '1', size: 2, }, { clientOid: 'je12019ka012ja013099', side: 'buy', symbol: 'XBTUSDTM', type: 'limit', price: '32150', leverage: '1', size: 2, }, ]; futuresClient.submitMultipleOrders(orders); ``` -------------------------------- ### GET /api/v3/announcements Source: https://github.com/tiagosiebler/kucoin-api/blob/master/docs/endpointFunctionList.md Retrieves announcements from KuCoin. ```APIDOC ## GET /api/v3/announcements ### Description Retrieves announcements from KuCoin. ### Method GET ### Endpoint `/api/v3/announcements` ### Parameters #### Query Parameters - **type** (string) - Optional - The type of announcement (e.g., 'trading', 'security'). - **lang** (string) - Optional - The language of the announcements (e.g., 'en', 'zh'). - **startAt** (integer) - Optional - Timestamp to filter announcements starting from. - **endAt** (integer) - Optional - Timestamp to filter announcements ending at. ### Request Example (No request body for GET requests) ### Response #### Success Response (200) - **code** (string) - The response code. - **msg** (string) - The response message. - **data** (array) - List of announcements. - **id** (string) - Announcement ID. - **title** (string) - Announcement title. - **content** (string) - Announcement content. - **type** (string) - Announcement type. - **createdAt** (integer) - Creation timestamp. #### Response Example ```json { "code": "200000", "msg": "success", "data": [ { "id": "ann123", "title": "Maintenance Schedule", "content": "Scheduled maintenance on...', "type": "security", "createdAt": 1678886400 } ] } ``` ```