What does the passphrase refer to?
The passphrase is the password you entered when requesting an API key. You must remember it yourself. If forgotten, it cannot be recovered, requiring you to create a new API key.
To trade on the demo disk API, follow these steps:
- Log in to your OKX account
- Navigate to Trading > Demo Trading
- Access Personal Center > Create Demo Account API Key
- Start demo trading
๐ Learn how to secure your API keys
Will the API key expire?
- Active Keys: API keys with transaction or withdrawal permissions expire after 14 days of inactivity.
- Read-Only Keys: IP-bound read-only keys never expire.
Activity is counted when:
- Calling private interfaces
- Accessing identity-verified account data (balances, billing, orders)
Can orders be placed in USDT or currency units via the API?
No. For contract orders:
- Default setting: Contract quantity
- Conversion between contracts/tokens requires using the contract-to-token conversion interface
Price movement formula:
(Current price - 24h opening price) / 24h opening price ร 100%
๐ Master contract trading strategies
Why does "51000 Parameter posSide error" occur?
First check your account mode (posMode):
- Hedge Mode: Requires posSide parameter (long/short)
- One-Way Mode: Only supports "net" or null posSide values
Verify via account settings interface.
How to get contract specifications?
Use the instrument information interface to retrieve:
- Contract nominal value (ctVal)
- Minimum order quantity (minSz)
What is the instId format?
Examples:
- Spot: BTC-USDT
- Perpetual Swap: BTC-USDT-SWAP (U standard)
- Futures: BTC-USDT-231230 (YYMMDD)
- Options: BTC-USD-231230-2000-C (Call)
All letters must be capitalized.
Why do TP/SL trigger price errors (51046-49) occur?
Trigger price rules:
- Sell Orders: TP > Last price, SL < Last price
- Buy Orders: TP < Last price, SL > Last price
What causes "50102 Timestamp expired" error?
Solution:
- Call system time interface
- Synchronize local time with server (UTC+8)
- Maintain <30 second time difference
Why "50101 APIKey environment mismatch"?
Cause:
- Real accounts: Must use real API keys (x-simulated-trading: 0)
- Demo accounts: Must use demo API keys (x-simulated-trading: 1)
Account mode error (51010)
Adjust via:
- API settings interface
- Web/app account mode settings (Main trading page > Account Mode)
Order quantity error (51121)
Orders must be multiples of minSz (minimum order size). Retrieve minSz from product interface.
Whitelist withdrawal error (58207)
Requirements:
- Add withdrawal address via web interface
- Complete Visa verification for unverified addresses
Timeout error (50004)
Typically occurs during:
- Capital fee collection times (00:00, 08:00, 16:00 UTC+8)
- Server high-load periods
If receiving 50004:
- Check order status separately
- Retry during lower-traffic periods
FAQ Section
How often should I rotate my API keys?
We recommend rotating keys every 90 days for security.
Can I use the same API key for multiple accounts?
No, each account requires unique API credentials.
What's the rate limit for API calls?
Standard accounts: 20 requests/second. Higher tiers available for institutional users.
How do I troubleshoot authentication failures?
- Verify timestamp synchronization
- Check API key permissions
- Confirm IP whitelisting (if enabled)
Where can I find API documentation?
Complete documentation is available in the developer portal.
Is there a sandbox environment for testing?
Yes, use demo API keys with x-simulated-trading:1 header.