Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/tiagosiebler/kucoin-api/llms.txt

Use this file to discover all available pages before exploring further.

The kucoin-api package is a professional, production-grade SDK for integrating with KuCoin’s full suite of REST APIs and WebSocket streams. It provides strongly-typed interfaces for every endpoint, an event-driven WebSocket client with automatic reconnection, and a convenient WebSocket API client that lets you trade over WebSocket as if you were calling a regular REST endpoint. Whether you are building spot bots, futures strategies, broker tooling, or real-time dashboards, this SDK removes all the low-level HTTP and WebSocket plumbing so you can focus on your logic.

Key Features

  • Complete API coverage — Dedicated REST clients for Spot, Futures, Broker, and Unified API operations, plus a unified WebSocket client for all markets.
  • Full TypeScript support — Strongly typed request parameters and response objects for every endpoint, with auto-generated type declarations.
  • Robust WebSocket handling — Configurable heartbeats, automatic reconnect-then-resubscribe workflows, and an reconnected event so your code stays in sync after any network hiccup.
  • WebSocket API client — Trade via WebSocket using a REST-like promise interface with WebsocketAPIClient, no raw WebSocket management required.
  • Browser-friendly signing — The default HMAC signature mechanism uses the Web Crypto API, making the SDK compatible with both Node.js and browser/bundler environments.
  • ESM + CJS — Ships with both module formats so it works out of the box in TypeScript ESM projects and CommonJS Node.js scripts alike.
  • Regional support — Built-in apiRegion option to route requests to KuCoin Global (kucoin.com), KuCoin EU (kucoin.eu), or KuCoin AU.
  • Proxy support — Axios-based HTTP layer with full proxy configuration.

REST API Clients

The SDK exposes four specialised REST clients, each targeting a distinct part of the KuCoin platform:

SpotClient

Spot trading, margin trading, account management, deposits, withdrawals, sub-accounts, and all spot market data endpoints.

FuturesClient

Futures order placement and management, positions, funding rates, risk limits, and futures market data.

BrokerClient

Broker and sub-account lifecycle management, rebate queries, and broker-specific transfer operations.

UnifiedAPIClient

KuCoin’s new-generation unified endpoints for cross-product market data across Spot, Futures, and Margin in one interface.

WebSocket Clients

WebsocketClient

A single unified WebSocket client for all public and private streams across Spot and Futures markets. Event-driven, with automatic connection management.

WebsocketAPIClient

A REST-like wrapper around KuCoin’s WebSocket API. Submit orders, cancel orders, and query state over an auto-managed WebSocket connection using async/await.

Installation

Install the package from npm using your preferred package manager:
npm install kucoin-api

Project Structure

kucoin-api/
├── src/
│   ├── SpotClient.ts          # Spot & margin REST client
│   ├── FuturesClient.ts       # Futures REST client
│   ├── BrokerClient.ts        # Broker REST client
│   ├── UnifiedAPIClient.ts    # Unified REST client
│   ├── WebsocketClient.ts     # Unified WebSocket client
│   ├── WebsocketAPIClient.ts  # WebSocket API (REST-like)
│   ├── lib/
│   │   ├── requestUtils.ts    # RestClientOptions, signing, URL routing
│   │   └── websocket/         # WebSocket internals & utilities
│   └── types/                 # TypeScript request/response types
└── examples/
    ├── Rest/                  # REST API usage examples
    ├── WebSockets/            # WebSocket usage examples
    └── auth/                  # Authentication examples
The examples/ directory on GitHub contains dozens of runnable TypeScript files covering every major use case. These are the canonical reference for real-world usage patterns.

Key Exports

The package re-exports everything you need from a single entry point. The most commonly used names are:
ExportKindDescription
SpotClientClassSpot & margin REST client
FuturesClientClassFutures REST client
BrokerClientClassBroker REST client
UnifiedAPIClientClassUnified Trading Account REST client
WebsocketClientClassUnified WebSocket client for all streams
WebsocketAPIClientClassREST-like WebSocket API client
DefaultLoggerConstant / TypeDefault logger used internally; spread and override to customise log output
WS_KEY_MAPConstantMap of all valid WebSocket connection keys (e.g. spotPublicV1, futuresPrivateV1)
WsTopicRequestInterfaceTyped topic-subscription object with optional payload used by WebsocketClient.subscribe()
RestClientOptionsInterfaceFull options object accepted by every REST client constructor
WSClientConfigurableOptionsInterfaceOptions accepted by WebsocketClient and WebsocketAPIClient constructors
import {
  SpotClient,
  FuturesClient,
  BrokerClient,
  UnifiedAPIClient,
  WebsocketClient,
  WebsocketAPIClient,
  DefaultLogger,
  WS_KEY_MAP,
} from 'kucoin-api';
import type {
  WsTopicRequest,
  RestClientOptions,
  WSClientConfigurableOptions,
} from 'kucoin-api';

Next Steps

Quickstart

Make your first public and private API call in under 5 minutes.

Authentication

Learn how to configure API keys, regions, access tokens, and custom signing.

Build docs developers (and LLMs) love