KuCoin JavaScript SDK example: rest-spot-public.ts

KuCoin REST spot public 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-spot-public.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-spot-public.ts.
  • Imports SDK symbols including SpotClient.
  • Calls SDK methods such as getSymbols(), getTicker(), getKlines().

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 { SpotClient } from 'kucoin-api'; async function start() {  const client = new SpotClient();   try {    // Fetch all symbols    const symbols = await client.getSymbols();    console.log('symbols:', JSON.stringify(symbols, null, 2));     // Fetch ticker for a specific symbol    const ticker = await client.getTicker({ symbol: 'BTC-USDT' });    console.log('ticker:', JSON.stringify(ticker, null, 2));     // Fetch klines for a specific symbol    const klines = await client.getKlines({      symbol: 'BTC-USDT',      type: '1day',    });    console.log(klines);  } 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.