Typed KuCoin
A fully typed, validated async client for the KuCoin API: Spot, Margin, Futures, Earn, VIP Lending, Affiliate, Convert, Copy Trading, Broker, and both public and private WebSocket feeds.
from typed_kucoin import KuCoin
async with KuCoin.new(public=True) as client:
ticker = await client.spot.ticker(symbol='BTC-USDT')
print(ticker['price'])Why Typed KuCoin?
- 🎯 Precise Types: every request and response across Spot, Margin, Futures and Earn is
a typed structure, not a bare
dict. - ✅ Runtime Validation: responses are checked against their schema by default, not just typed on paper.
- ⚡ Async First: one client shares an HTTP connection pool per KuCoin host (default, futures, broker) and lazily opens the Spot/Margin WebSocket connection only when a stream is used.
- 📚 Full Surface: Account, Spot, Margin, Futures, Earn, VIP Lending, Affiliate, Convert,
Copy Trading and Broker each hang off their own attribute on
KuCoin, alongside the Spot/Margin public and private WebSocket feeds.
Installation
pip install typed-kucoinQuickstart
from typed_kucoin import KuCoin
async with KuCoin.new() as client:
accounts = await client.account.spot_accounts()
print(accounts)KuCoin.new() reads KUCOIN_API_KEY, KUCOIN_API_SECRET and KUCOIN_API_PASSPHRASE from
the environment. Pass public=True for a credential-free client restricted to public
endpoints — see API Keys Setup.
Client Surface
client.account, client.spot, client.margin, client.earn, client.vip_lending,
client.affiliate, client.convert, client.futures, client.copy_trading and
client.broker cover REST. client.streams.spot_margin and client.streams.futures
cover WebSocket (each is public and private topics on one connection) — see
Listen To Streams.
Documentation
How To
- Fetch Market Data
- Listen To Streams
- Place & Manage Orders
- Manage Account Data
- Query & Manage Earn Instruments
- Deposits & Withdrawals
- Paginate Through Results
Reference
Design Philosophy
Typed KuCoin follows the principles outlined in this blog post.
Details matter. Developer experience matters.