Connecting your OKX account via API saves hours of manual data entry and ensures accurate transaction tracking. This guide walks you through the exact steps to generate your API key, configure proper permissions, and sync your trading history—covering the three-month retrieval window, security settings, and common setup issues.
Before generating your API key, it's worth knowing what transaction data you can actually retrieve. OKX's API provides comprehensive trading history, but there are a few specific limitations to keep in mind.
Supported Transaction Types:
Most standard transactions sync automatically through the API—spot trades, futures, distributions, and more. However, margin trading has one notable gap: "borrow" and "repay" records aren't available through the API due to exchange restrictions. If you need these records, you'll have to upload them manually using a custom file format.
As of March 31, 2025, transactions from "Shark Fin" and "Seagull" features also can't be retrieved via API because the exchange doesn't provide sufficient data for these products.
Time Period Restrictions:
Here's where timing matters. Distribution history is available from February 1, 2025 onward, but all other transaction types only go back three months. This means if you're setting up your API connection today, you can only automatically pull the last three months of trading data (except distributions).
For anything older than that three-month window, you'll need to manually upload historical records using custom files. And here's the important part: you need to manually re-sync your API at least once every three months to keep your data current, since older transactions fall outside the retrieval window.
Getting your API key set up correctly the first time prevents security issues and sync failures down the road. Here's the exact process.
Step 1: Access the API Menu
Log into your OKX account, click your profile icon in the upper right corner, and select the "API" menu option.
Step 2: Create a New API Key
Click the "Create V5 API key" button. This opens the configuration screen where you'll set your permissions and security settings.
Step 3: Configure Your API Settings
This is where most people make mistakes, so pay attention to these fields:
API Type: Select "API trading"
API Name: Enter any descriptive name you'll remember (like "CryptoTax-Sync")
Passphrase: Create and save a strong passphrase—you'll need this later
IP Allowlist (Optional but Recommended): Add these specific IPs for enhanced security:
52.69.115.51
18.179.74.94
52.193.138.38
Permissions: Select "Read" only—you don't need write or trade permissions for transaction history retrieval
Click "Confirm" once you've filled everything out.
Step 4: Complete Two-Factor Authentication
OKX will prompt you to verify through email and your authentication app. Enter both codes and click "Confirm" to proceed.
Step 5: Save Your Credentials
This is critical: OKX displays your API key and Secret key only once. Copy both immediately and store them securely. You won't be able to view the Secret key again—if you lose it, you'll have to generate a new API key from scratch.
Once you have your credentials, the connection process is straightforward. Navigate to the API connection screen in your crypto tax or portfolio tracking platform, select OKX as your exchange, and enter three pieces of information: your API key, Secret key, and the Passphrase you created.
If you're looking for a reliable platform that handles OKX data efficiently, 👉 OKX offers seamless API integration with industry-leading security standards—perfect for automated transaction tracking. The platform's three-month rolling data window means you'll want to set a reminder to manually click the "Sync" button every couple of months to keep your records complete.
After your initial sync completes, new transactions won't appear automatically—you'll need to manually trigger a sync whenever you want to update your transaction history. This design gives you control over when data updates happen rather than running constant background syncs.
API Key Security:
Always generate read-only API keys for transaction history purposes. Never grant trade or withdrawal permissions unless absolutely necessary for a specific use case. The IP allowlist adds an extra security layer—only the specified servers can use your API key, even if someone else obtains your credentials.
Common Setup Issues:
If your sync fails, double-check that you selected V5 API (not V3 or earlier versions) and that you granted "Read" permissions. Also verify you're within the three-month retrieval window for most transactions.
Data Gaps:
Remember that margin borrow/repay records and Shark Fin transactions won't sync via API. For complete tax records, you'll need to supplement your API data with manual uploads for these specific transaction types.
Getting your OKX API key configured correctly means accurate transaction records without manual data entry headaches. The three-month retrieval window requires regular attention, but the automation saves significant time compared to manual CSV uploads.
For traders managing multiple exchanges or complex strategies, 👉 OKX provides robust API documentation and reliable data access, making it a solid choice for both casual and professional traders. Just remember to re-sync every three months and manually handle those margin borrowing records, and you'll maintain complete transaction history without gaps.
Important Disclaimer: API connections carry inherent security risks. Use only the read-only permissions specified in this guide, never share your Secret key, and understand that unauthorized access or accidents resulting from API connections are your responsibility. When in doubt, regenerate your API key and update your connection with fresh credentials.