If you've been trading on OKX for a while, there comes a moment when clicking buttons manually starts to feel like shoveling snow with a spoon. You see an opportunity, you hesitate for a second, and it's gone. That's exactly why OKX API keys exist — they're the bridge between your strategy and the market, letting bots, scripts, and third-party platforms act on your behalf without ever touching your withdrawal funds.
This guide walks you through everything: what an OKX API key actually is, how to create one safely, which permissions to enable (and which to never touch), and how OKX's fee structure rewards traders who move more volume. Whether you're connecting a trading bot or building your own automated system, you're in the right place.
An API key is essentially a digital credential — a set of strings that gives an external application permission to interact with your OKX account. Think of it like a valet key for your car: it lets someone drive it, but it doesn't open the trunk where your valuables are stored.
When you create an OKX API key, you get three components:
- API Key — the public identifier (like a username)
- Secret Key — the private signing key (like a password, never share this)
- Passphrase — an extra layer of security you set yourself during creation
Together, these three strings authenticate every request your bot or app sends to OKX. No manual login required. No 2FA prompt every five minutes. Just clean, fast, automated execution.
The practical use cases are wide: algorithmic trading bots, portfolio trackers, tax reporting tools, copy-trading platforms, custom dashboards — anything that needs to read your account data or place trades on your behalf.
Ready to get started? 👉 Sign up for OKX with 20% fee rebate and then follow the steps below.
OKX has a few prerequisites before you can generate your first API key:
- Verified account — your identity verification (KYC) must be complete
- Minimum balance — OKX requires at least $100 USD equivalent in your account to activate API key creation
- Two-Factor Authentication — 2FA must be enabled via Google Authenticator or SMS
- Correct environment — OKX maintains completely separate API keys for live trading and demo trading; make sure you're creating the right one
If you haven't signed up yet, 👉 create your OKX account here — new users currently get a 20% commission rebate on trading fees with invitation code CASH20.
The process is straightforward once you know where to look. Here's the full walkthrough:
After logging into your OKX account, click the user icon in the top-right corner. From the dropdown menu, select "API". This opens the API management dashboard where all your keys live.
OKX lets you create API keys scoped to different account types — your main trading account, sub-accounts, etc. Choose the account you want the API key to operate on. For most bot setups, this will be your primary unified account.
Hit the "Create V5 API Key" button. OKX has moved to the V5 API as their standard; it's more powerful and better documented than previous versions.
Give your key a descriptive name — something like "bitsgap-bot-main" or "portfolio-tracker" — so you can identify it later if you have multiple keys. Then set a passphrase: this is a custom string you create, and you'll need it every time you use the key. Write it down somewhere secure.
This is the most important step. OKX API permissions break down into several categories:
| Permission | What It Does | Recommended? |
|---|---|---|
| Read | View balances, orders, positions, history | ✅ Always enable |
| Trade | Place, modify, and cancel orders | ✅ Enable for trading bots |
| Withdrawal | Initiate fund withdrawals | ❌ Never enable unless absolutely necessary |
| Transfer | Move funds between accounts |
The golden rule: disable withdrawal permissions. If your API key is ever compromised, an attacker with withdrawal access can drain your account. With trading permissions only, the worst case is unauthorized trades — bad, but recoverable.
After setting permissions, add your IP whitelist. This restricts the API key to only accept requests from specific IP addresses — your bot server's IP, for example. If an unauthorized IP tries to use your key, OKX blocks the request entirely.
For bots running on a VPS or cloud server, add that server's static IP here. For local setups, add your home IP. If you're connecting a third-party service like Bitsgap, Gunbot, or Alertatron, they'll tell you which IP ranges to whitelist.
OKX will prompt a 2FA verification before finalizing the key. Complete this step, and your API key details will be displayed — this is the only time the Secret Key is shown in full. Copy all three values (API Key, Secret Key, Passphrase) and store them in a password manager immediately.
Paste your credentials into whatever trading tool you're using. Most platforms (Bitsgap, Wundertrading, 3Commas, Alertatron, etc.) have a dedicated OKX integration page where you enter the three values. Follow the specific platform's instructions from there.
Beyond the basic Read/Trade split, OKX's V5 API supports granular endpoint access across several trading modes:
Spot Trading — place market, limit, stop, and advanced orders on spot pairs Futures and Perpetuals — manage positions, set leverage, handle funding rate-sensitive strategies Options — access OKX's options market programmatically Portfolio Margin — available at higher API access levels for cross-margin strategies
The API also supports both REST (request-response, good for order execution) and WebSocket (real-time streaming, good for market data and live position monitoring). Most trading bots use both: REST for placing orders, WebSocket for watching price feeds.
Here's where it gets interesting for active traders. OKX uses a VIP tier system that determines your trading fees based on either your 30-day trading volume or your total assets — whichever qualifies you for the higher tier. The more you trade or hold, the less you pay per trade.
| Tier | 30-Day Volume (or Assets) | Maker Fee | Taker Fee |
|---|---|---|---|
| Regular | < $10M | 0.080% | 0.100% |
| VIP 1 | ≥ $10M or ≥ 10K OKB | 0.070% | 0.090% |
| VIP 2 | ≥ $50M or ≥ 20K OKB | 0.060% | 0.080% |
| VIP 3 | ≥ $200M or ≥ 50K OKB | 0.050% | 0.070% |
| VIP 4 | ≥ $500M | 0.030% | 0.060% |
| VIP 5+ | ≥ $1B+ | Negotiated | Negotiated |
| Tier | 30-Day Volume (or Assets) | Maker Fee | Taker Fee |
|---|---|---|---|
| Regular | < $10M | 0.020% | 0.050% |
| VIP 1 | ≥ $10M or ≥ 10K OKB | 0.015% | 0.040% |
| VIP 2 | ≥ $50M or ≥ 20K OKB | 0.010% | 0.030% |
| VIP 3 | ≥ $200M or ≥ 50K OKB | 0.000% | 0.025% |
| VIP 4 | ≥ $500M | -0.010% | 0.020% |
| VIP 5+ | ≥ $1B+ | Negative | Negotiated |
A few things worth noting:
- Negative maker fees at VIP 4+ on futures means OKX pays you for providing liquidity. At scale, this flips fee costs into fee income.
- OKB holdings (OKX's native token) can qualify you for VIP tiers independently of your trading volume — meaning you can get discounted fees just by holding OKB.
- OKB discount stacking: Holding OKB unlocks an additional 10%–40% fee discount on top of your tier rate.
- Tier status recalculates daily based on a rolling 30-day window.
For bots running high-frequency strategies, the difference between Regular (0.10% taker) and VIP 3 (0.025% taker) on futures is enormous over thousands of trades. This is why serious algo traders optimize for tier progression alongside their strategy.
👉 Register with the CASH20 invitation code to start at an immediate 20% fee rebate while building toward higher VIP tiers.
The most popular use. Bots like Gunbot, Bitsgap, and Wundertrading connect via your API key to execute strategies 24/7 — grid trading, DCA accumulation, momentum following, arbitrage across pairs. Your key needs Read + Trade permissions; withdrawal stays off.
Developers building their own Python or JavaScript scripts use the OKX V5 REST API directly. The official docs at OKX's developer portal cover authentication, rate limits, and all available endpoints. Useful for backtesting pipelines that need live data alongside historical feeds.
Tools like CoinTracking or custom dashboards only need Read permissions — no trading access required. This is the safest API key configuration: even if the credentials leak, nothing can be bought or sold.
Crypto tax platforms pull your full trade history via API to calculate gains, losses, and taxable events. Again, Read-only is all they need.
OKX has its own copy trading feature, but third-party platforms can also mirror trades across accounts using API keys — one master account with a Trade key, follower accounts with their own keys.
A few habits that separate careful traders from the ones who post horror stories on Reddit:
1. One key per application. Don't reuse the same API key across multiple bots or services. If one platform has a security incident, you can revoke that single key without disrupting everything else.
2. Review your keys regularly. OKX's API management page shows last-used timestamps. If a key you don't recognize is active, or a key shows recent activity when it shouldn't — revoke it immediately.
3. Rotate keys periodically. Even without a breach, creating fresh keys every few months and retiring old ones reduces your attack surface.
4. Never share keys in plain text. If a support team ever asks for your API key or secret in a chat or email, that's a scam. OKX support will never ask for this.
5. Use sub-accounts for bots. OKX allows sub-accounts that sit under your main account. Running your bot under a sub-account means its API key only has access to that sub-account's funds — limiting blast radius if something goes wrong.
6. Monitor for unusual activity. Set up alerts for large trades or unexpected position changes. Some monitoring tools can watch your account via API and ping you if something looks off.
One often-overlooked feature: OKX maintains a complete demo trading environment with its own separate API keys. Before connecting any new bot to a live account, you can test your entire setup — key creation, permission configuration, order execution — against paper money.
To access demo trading, switch your OKX account to Demo mode, then create a new API key from within that environment. Use these credentials exclusively with your bot's test configuration. When everything checks out, create a fresh live key and switch over.
This is especially useful when setting up complex multi-leg strategies or testing a new bot platform for the first time.
Q: How many API keys can I create on OKX? OKX allows up to 5 API keys per account. Sub-accounts each have their own limit as well.
Q: What happens if I lose my Secret Key? It can't be recovered — OKX only displays it once at creation. You'll need to delete the old key and create a new one. This is why secure storage matters from day one.
Q: Can I change permissions on an existing API key? Yes. Go to API management, find your key, and edit its permission settings. Changes take effect immediately.
Q: Does creating an API key affect my account security? It can, if configured carelessly. Enabling withdrawal permissions on a key that gets compromised is the main risk. With withdrawal disabled and IP whitelisting active, the exposure is limited.
Q: Can my bot lose more than my account balance? On spot trading, no — you can't sell more than you hold. On futures with leverage, your position can be liquidated if the market moves against you, but the bot can't create debt beyond your margin.
Q: Is there a rate limit on the OKX API? Yes. OKX has rate limits per endpoint. For most trading use cases, the limits are generous enough that standard bots don't hit them. High-frequency strategies operating at millisecond speed may need to optimize request batching.
If you're reading this guide, you're probably a few steps away from having your first automated strategy live on OKX. Here's the sequence that makes sense:
- 👉 Create your OKX account with invitation code CASH20 — locking in a 20% rebate on fees from day one
- Complete identity verification and enable 2FA
- Fund your account (minimum $100 to unlock API creation)
- Create a demo API key and test your bot setup in the paper trading environment
- Once confirmed working, create a live API key with appropriate permissions and IP whitelist
- Monitor your first live trades and verify the bot's behavior matches your expectations
The OKX API is genuinely one of the more developer-friendly setups in crypto — clean V5 documentation, robust WebSocket feeds, and a wide range of supported order types. Whether you're running a simple DCA bot or a more sophisticated systematic strategy, the infrastructure is there to support it.
The only thing left is to actually start. 👉 Get your OKX account here and start building.