TheDocumentation 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.
kucoin-api SDK is designed to work in both Node.js and browser environments. In the browser, it replaces Node.js’s crypto module with the standardised Web Crypto API (globalThis.crypto.subtle) for HMAC-SHA256 request signing. A webpack configuration is included in the repository to produce a ready-to-use UMD bundle that any <script> tag or module bundler can consume.
How Browser Signing Works
In Node.js, HMAC signatures are traditionally computed with the built-incrypto module. Browsers do not expose require('crypto'), so the SDK implements the same signature logic through the Web Crypto API instead. The key function in src/lib/webCryptoAPI.ts looks like this:
globalThis.crypto, which is available in all modern browsers (Chrome, Firefox, Safari, Edge) as well as Node.js v18+ and Deno — no polyfill needed.
If you are on Node.js, the SDK checks for Web Crypto API availability at construction time when credentials are supplied. Node.js v18 reached end-of-life in April 2025. Use Node.js LTS (v22 or above) to ensure
globalThis.crypto is available.Node.js-only Features Excluded from Browser Builds
Thehttps.Agent (used for the keepAlive REST option) is Node.js-only. The webpack configuration explicitly excludes it so the browser bundle remains clean:
keepAlive: true in a browser context, the SDK silently skips the https.Agent setup — browsers manage connection pooling automatically.
Building the Browser Bundle
The repository ships a webpack config that compiles the pre-built CJS output into a single UMD bundle suitable for direct<script> tag inclusion or integration into frontend projects.
Install dependencies
From the root of the
kucoin-api repository, install all Node.js dependencies including the webpack build toolchain:Compile TypeScript
Compile the TypeScript source to both ESM and CJS output in the This runs
dist/ directory:tsc twice — once for ESM (dist/mjs/) and once for CJS (dist/cjs/) — then runs the post-build shell script.Bundle with webpack
Run webpack to produce a single UMD bundle in The webpack config (
dist/kucoinapi.js:webpack/webpack.config.cjs) reads from dist/cjs/index.js as its entry point and outputs a kucoinapi UMD library:ESM and CJS Exports
The published npm package exposes both module formats via theexports field in package.json:
- ESM (
import): used by Vite, modern webpack, Rollup, and anytype: "module"project. - CJS (
require): used by legacy Node.js scripts and older toolchains.
Security: Never Expose API Keys in the Browser
The browser bundle is safe to use for public, unauthenticated endpoints — fetching tickers, order books, klines, and symbol lists — because those require no credentials. For anything that requires authentication, use a backend proxy pattern:Safe in the browser
- Market data (tickers, order books, klines)
- Symbol lists and exchange info
- Public WebSocket streams
Keep on the backend
- Order placement and cancellation
- Account balance queries
- Private WebSocket streams
- Any call that uses API key/secret
Recommended: Backend Proxy Pattern
The recommended architecture for browser-based trading dashboards is to route authenticated calls through a server you control:Using the Custom Sign Function for Performance
If you are running in a backend Node.js environment and need maximum signing throughput, you can optionally swap the Web Crypto API signer for Node’s faster nativecreateHmac: