KuCoin API Integration in Mobile Crypto Applications
KuCoin stands out among exchanges because WebSocket connection requires obtaining a token via REST first—without this token, you can't connect to WebSocket at all. This architecture surprises developers accustomed to Binance or Bybit, where public streams are directly accessible.
Token for WebSocket: Mandatory First Step
POST /api/v1/bullet-public — for public data (no signature).
POST /api/v1/bullet-private — for private data (with HMAC-SHA256 signature).
Response contains token, instanceServers (list of WebSocket servers with endpoint and pingInterval), and token lifetime (tokenValidFor in milliseconds, usually 18000000—5 hours).
Connection: wss://{endpoint}?token={token}&connectId={random_uuid}. connectId is any unique session identifier for KuCoin debugging.
On connection break, request a new token (old may expire) and reconnect. If you just reconnect with the same token, it sometimes works, sometimes doesn't. More reliable to always request a new token.
REST API Signature
Format is standard: KC-API-SIGN: Base64(HMAC-SHA256(timestamp + method + endpoint + body)). Separate headers KC-API-PARTNER and KC-API-PARTNER-SIGN are required only for broker integrations—regular mobile apps don't need them.
KuCoin adds KC-API-KEY-VERSION: "2" — mandatory header for keys created after 2021. Without it, API returns {"code":"400007","msg":"Invalid KC-API-KEY-VERSION"} even with correct signature.
Trading Features: Hummingbot-Specific Not Needed
KuCoin is actively used by bots (they even have official Hummingbot connector), so rate limiting is strict for IPs without User-Agent header from known bots. Mobile apps get standard limits: 1800 requests/minute for public API, 200 for private. Problems start only with aggressive polling.
KuCoin Futures—separate domain (api-futures.kucoin.com) with own authentication and endpoint set. If you need both Spot and Futures integration—that's two different API clients.
Order Book via WebSocket
KuCoin splits OrderBook: /market/level2:{symbol} (incremental updates with sequence numbers) and /spotMarket/level2Depth5:{symbol} (top-5 best prices, full snapshot per update). For order book 20+ levels deep, use the first variant.
Order book recovery algorithm:
- Subscribe to
level2stream - Request snapshot via REST
GET /api/v3/market/orderbook/level2?symbol=BTC-USDT— returnssequence - Apply only deltas where
sequenceStart > snapshot.sequence - If delta arrives with
sequenceStart > lastApplied + 1— gap exists, need new snapshot
This is a standard scheme, but KuCoin adds sequenceStart and sequenceEnd to each delta message (not a single number), which must be accounted for in validation.
Timeline
Basic KuCoin Spot integration—2–3 weeks. Specifics (token for WebSocket, key versioning, order book recovery) add roughly a week compared to Binance. Futures—separate assessment.







