KuCoin trading bot: the three-part key, ccxt and the sandbox

KuCoin is a popular altcoin-heavy exchange with built-in trading bots and an open API. The one thing that trips up newcomers is KuCoin's three-part credential: unlike most exchanges, a KuCoin API key needs a key, a secret and a passphrase you set yourself. Get all three into ccxt and the rest is familiar territory. This guide covers the credential, the connection, spot orders and KuCoin's sandbox.

On this page
  1. Why KuCoin
  2. The passphrase credential
  3. Connecting with ccxt
  4. The sandbox
  5. Placing an order
  6. Safe start

Why traders pick KuCoin

Altcoin liquidity is thinner than majors, so test how slippage eats your edge on the backtester before trading small caps live.

Step 1 — the three-part credential

When you create a KuCoin API key you set a passphrase yourself. That passphrase is required on every signed request alongside the key and secret — miss it and every private call returns an auth error.

Trade-only, no withdrawals

Enable General and Trade permissions; leave Transfer/Withdraw off. Whitelist your server IP, and store the key, secret and passphrase as three separate environment variables.

Step 2 — connect with ccxt

python · kucoin_connect.pyimport ccxt, os
ex = ccxt.kucoin({
    'apiKey': os.environ['KUCOIN_KEY'],
    'secret': os.environ['KUCOIN_SECRET'],
    'password': os.environ['KUCOIN_PASSPHRASE'],  # the 3rd part!
    'enableRateLimit': True,
})
print(ex.fetch_balance()['USDT']['free'])
API key secret passphrase all three sign every private request — miss one and auth fails
KuCoin's signature needs all three; the passphrase is the part most first-time bot builders forget.

Step 3 — use the sandbox

KuCoin offers a sandbox with separate credentials and fake funds. Point ccxt at it with set_sandbox_mode(True) and validate your full order flow before touching real balances.

python · kucoin_sandbox.pyex.set_sandbox_mode(True)   # requires sandbox API keys

Step 4 — place a spot order

python · kucoin_order.pyif signal() == 'buy':
    o = ex.create_market_buy_order('BTC/USDT', 0.001)
    print('order', o['id'])
Mind altcoin slippage

Thin books mean market orders can fill far from the last price. Use limit orders on small caps and size with the position calculator.

Safe-start checklist

  1. Edge survives fees and realistic slippage on the backtester.
  2. Key + secret + passphrase set; trade-only, no withdrawals.
  3. Full order loop validated in the sandbox.
  4. Limit orders on illiquid pairs; tiny size first.
  5. Kill switch on a max-drawdown threshold.
Not financial advice. This content is educational. Automated and algorithmic trading carries a real risk of financial loss. Never trade money you cannot afford to lose. Review the SEC investor.gov and CFTC resources before trading.

Frequently asked questions

Why does KuCoin need a passphrase for its API?

KuCoin uses a three-part credential: the API key, the secret and a passphrase you choose when creating the key. All three are required to sign every private request. In ccxt you pass the passphrase as the 'password' field — leaving it out causes authentication errors.

Does KuCoin have a sandbox for bots?

Yes. KuCoin provides a sandbox environment with separate API credentials and fake funds. Calling set_sandbox_mode(True) in ccxt points your bot there so you can validate the full order flow before risking real money.

Is KuCoin safe for automated trading?

KuCoin's API is reliable and supported by ccxt, but it lists many thin-liquidity altcoins where market orders can slip badly. Use trade-only keys with no withdrawal rights, prefer limit orders on small caps, and keep position sizes conservative.

Can I build a free KuCoin bot?

Yes. The KuCoin API is free apart from standard trading fees, and ccxt is open-source. A self-hosted Python or JavaScript bot costs nothing beyond hosting. Always backtest the strategy first on our free tool.

MB

Mustafa Bilgic

Algorithmic trading practitioner · Founder, AITradingBot.us

Mustafa builds and backtests automated trading systems and writes about them without the hype. Every tool on this site is free and runs entirely in your browser.