Home β€Ί APIs β€Ί OKX

OKX API β€” how to get keys, cost & limits

OKX's v5 API covers spot, perpetual/futures swaps, options and market data over REST and WebSocket. One quirk: OKX keys come as three parts β€” API key, secret and a passphrase. Here's how to get them.

What the API does & cost

UseCost
Market data (REST/WS)Free
Spot trading fee~0.08–0.1%
Perpetual swaps (taker)~0.05%
API accessFree
⚠️ The OKX API is free to use β€” you only pay trading fees on the trades it places. Fees and limits change; confirm on the official docs. Market-data (read-only) endpoints cost nothing.
New to OKX?
Create an account with our referral link β€” new users can get fee discounts and a welcome reward. You support APICostCalc (we earn a small share of fees, at no extra cost to you).
Sign up on OKX β†’

How to get your OKX API keys (step by step)

1. Sign up / log in at okx.com and complete verification.
2. Go to Account β†’ API and click Create V5 API Key.
3. Set a passphrase (you choose it β€” you'll need it on every request), pick permissions (Read / Trade) and add an IP whitelist.
4. Copy the API Key, Secret and remember your passphrase β€” all three are required to authenticate.

Quick test

# public ticker β€” no key needed (v5)
curl "https://www.okx.com/api/v5/market/ticker?instId=BTC-USDT"

Security β€” read this

OKX needs three secrets (key, secret, passphrase) β€” protect all of them. Use Read-only for data bots, IP-whitelist for trade keys, and never enable withdrawals on an API key unless you must. Keep them in environment variables.

Alternatives

Binance for liquidity, Bybit for low perp fees. Just need prices? CoinGecko. See Binance and Bybit.

Browse all API guides β†’ Β· trade safely β€” size positions with RektCalc.

Not affiliated with OKX. Exchange link is a referral link.