Skip to content

Public market data ​

Use SpotClient for Classic Spot market data. These requests need no credentials and use live services.

ts
import { SpotClient } from 'kucoin-api';

async function main() {
  const client = new SpotClient({}, { timeout: 10000 });
  const symbol = 'BTC-USDT';
  const rules = await client.getSymbols();
  console.log(
    'Pair rules:',
    rules.data.find((pair) => pair.symbol === symbol),
  );
  const book = await client.getOrderBookLevel20({ symbol });
  console.log('Best bid:', book.data.bids[0], 'Best ask:', book.data.asks[0]);
  const candles = await client.getKlines({ symbol, type: '1hour' });
  console.log('Candles:', candles.data);
}

main().catch(() => {
  console.error('Public market-data request failed.');
  process.exitCode = 1;
});

Prices and quantities ​

Successful responses retain KuCoin's code and data envelope. Read the ticker at response.data.price, the book at response.data.bids and response.data.asks, and symbol rules from response.data returned by getSymbols().

Price and size fields are decimal strings. Preserve them through trading calculations or use a decimal library; converting to JavaScript numbers can lose precision. Book levels are [price, size] pairs.

Before placing an order, check the symbol's enableTrading, increments, minimum size and minFunds. Pair rules can change. A book snapshot is not a continuously maintained local order book.

Candles and time units ​

getKlines() uses type values such as 1min and 1hour. Its startAt and endAt bounds are Unix seconds, not milliseconds. Candle tuples contain [time, open, close, high, low, volume, turnover]; the time is a string containing Unix seconds.

Do not assume every interval has a candle or that responses are in ascending time order. Sort and deduplicate when combining overlapping requests, and treat the current candle as incomplete.

Other products ​

Use FuturesClient for Classic futures and UnifiedAPIClient for UTA market data. Choose symbols and request parameters from each product's reference instead of substituting a Spot symbol into a futures call.

Streaming updates · SpotClient reference

Built by Siebly. Open source SDKs for exchange APIs.