Connecting to the OKX exchange
Connecting to the OKX exchange
We recommend registering an account on the OKX exchange using Moonbot’s referral link: 🔗 https://okx.com/join/JOINMOONBOT
Anyone who registers via this link will automatically receive 20% cashback on spot and futures trading, and the option to activate a free one-month trial of the PRO version.
Once you have activated the PRO version using Moonbot’s referral link, you will have access to the following bonuses:
-
OKX’s auto-purchase option for tokens;
-
The MoonHook Strategy;
-
A tool for emulating prices on a chart using the Pencil;
-
Module for monitoring graphs in separate windows;
-
The MoonKernel module – a client-kernel mode designed to speed up manual trading.
If your OKX exchange account was registered via a different referral link, you can re-register it with our referral programme. To do this:
-
Please follow this link: https://www.okx.com/ul/J6l2R5
-
In the "Invite Code" field, enter the code: JOINMOONBOT
-
In the "Reason for joining" field, please enter: "I would like to become a Moonbot referral" and you will be transferred within 24 hours.
The Moonbot terminal for OKX supports trading on spot and futures markets.
When using the Moonbot terminal for OKX on a dedicated server, it is best to select the "Tokyo (Japan)" location for the best ping.
Sub-accounts are activated via the Moon Credits window (instructions are provided below); 500 Moon Credits are required to activate each subsequent sub-account . Moon Credits are available only to users of the PRO version of Moonbot.
Instructions for creating API keys in your OKX exchange account
Once you have logged into your OKX account and completed the verification process:
1) In your account settings, click on "API and connections" and, on the "API and connections" page, click on "+ Create API key".
2) The “OKX API Agreement” window will appear: By continuing, you confirm that you've read, understood and agree to be bound by the OKX API Agreement. Click the Continue button.
3) The page "Create API keys" will open; here, you need to fill in the fields and tick the relevant boxes.
-
Basic info
API key name – enter any name you like for the API Key, for example MOONBOT
Account – when creating an API key on the main account, this field will display "Main account"; when creating an API key on a sub-account, it will say "Sub-account".
Used for should be left as API trading.
-
Permissions
The Read tick box is selected by default; please also tick the Trade tick box.
You need at least 100 USD in total assets to create API keys with Trade or Withdraw permissions.
Markets - tick the boxes for Spot & Margin and Perpetual.
Crypto – click on the "+ Add" button; in the new window, click on "Select all" and then click on the Confirm button below.
-
Security
Trusted IP addresses: if the slider is enabled, a field will appear for adding up to 20 IPv4 or IPv6 addresses, separated by commas or spaces, from which trading may take place. If the slider is disabled, a warning will be displayed stating that anyone with this API key can exercise all permissions from any device or network. Keys with more than Read permissions expire after 14 days of inactivity, unless they’re linked to an IP address.
Passphrase for using API keys in the Moonbot terminal: you must always enter the following in this field: Okx!00000.
Once you have finished entering your API key details, click the Submit All button.
Next, complete all the necessary verification steps to create an API key (enter the security codes and complete the identity verification).
Once you have completed these steps, the API keys will have been successfully created.
On the "API and Connections" page, a row will appear showing the API keys you have created. In the Actions column on the right, click the Details button to view the API key and Secret key, click on View credentials, complete the security procedures, and the API key and Secret key fields will appear with asterisks; click on the eye icon to reveal the API key details.
⚠️ Important! Save your API key and Secret key in a text file on a USB stick or write them down on paper — you’ll need these keys to register them in the Moonbot terminal (under the Settings → Login tab).
Each main account and sub-account may contain up to 50 active API keys.
Procedure for activating API keys in the OKX exchange terminal
-
Create API keys for your main account or sub-account on the OKX exchange website. Your account balance must contain assets worth at least 100 USD;
-
Please ensure that your trading funds have been transferred from the "Funding" to the "Trading". If there are no funds in the “Trading”, the Moonbot terminal will be unable to connect to the exchange, and errors such as “Get full balance: ERROR RestBalance:" and "Last Error: RestBalance:".
-
Copy the folder containing your main PRO terminal for the other exchange into a new folder and launch the terminal;
-
Go to Settings → Login, in the Exchange field, select OKX (for spot trading) or OKX Futures (for futures trading) and click the Apply button;
-
In the Settings → Login section, register the API keys for your main account or sub-account;
-
In the bottom-right corner of the Moonbot terminal’s main window, click on the text PRO version to open the Moon Credits window, which contains the activations for the paid modules (see the figure below);
-
The Moon Credits window displays your Moon Credits balance at the bottom; 500 Moon Credits are required to activate the main account or a single sub-account; if your balance is sufficient, in the Activate API Key section, click the Activate for 500 Credits button — the API keys will be activated in this terminal;
-
If you need to activate additional sub-accounts on the same exchange, repeat the procedure as many times as necessary.
Key points to note when using the OKX exchange
To connect the terminal to the OKX exchange and ensure it works correctly, please note the following points:
-
The OKX exchange has its own token – OKB – but the exchange’s fees are not charged in OKB. The base rates (for example, 0.08% for makers and 0.1% for takers on the spot market) apply regardless of OKB holdings. However, OKB token holders can receive a discount on trading fees – of up to 40% off the base rate. In other words, the token is not a source of fees, but serves as a tool to reduce them;
How this works in practice: if you hold OKB in your account, the exchange will apply a discount to the standard fee when you place a trade. And the more tokens you hold, the more substantial the discount can be. Furthermore, OKB discounts can be combined with other mechanisms – for example, by advancing to a higher tier in the VIP programme through high trading volume.
Information on fees for the OKX exchange: https://www.okx.com/fees
If you have sub-accounts, your fee tier will be determined by the combined 30-day trading volume and daily asset balance across all main and sub-accounts. Each account will enjoy the same fee tier benefits. If you create a new sub-account, your fee tier benefits for that account will take effect at 16:00 (UTC).
Users are classified into standard and VIP tiers based on their deposit total or trading volume over the previous 30 days. A user’s tier determines their trading fees for the following trading day.
Your fee tier for OKX trading instruments is calculated according to various criteria. If you meet the criteria for more than one tier, the terms of the highest tier will apply to you. For example, if your 30-day spot trading volume is 5,000,000 USD (corresponding to VIP Level 2), and your 30-day futures trading volume is 10,000,000 USD (corresponding to VIP 3), you will receive VIP 3 commission rates for all instruments.
-
"Hedge mode" is supported in the terminal (except for Portfolio margin). If you need to switch to “Hedge mode”, the exchange has the following requirement: “you may switch modes, but only if you have no open positions or orders”.
-
API limits: OKX does not return remaining quota balances in the headers, meaning the Moonbot terminal cannot see how much of the limit is left. Order limits are calculated separately for each instrument, plus an overall cap of 1,000 order requests per account every 2 seconds;
-
The Moonbot terminal utilises certain undocumented functions of the OKX exchange API, such as deep-level aggregation channels (as found on exchanges such as Bybit and BitGet); the number of levels may be reduced if the exchange disables the relevant function;
-
OKX’s servers have been relocated from the “Hong Kong” location to the “Tokyo (Japan)” location since the end of July 2026, so please select the same location when trading on dedicated servers;
-
The iceberg order mode is not supported;
-
Account mode:
Spot mode – in this mode, only the OKX (Spot) connection works in Moonbot; OKX Futures is not supported
Futures mode - In this mode, both OKX (Spot) and OKX Futures are supported in Moonbot
Multi-currency - In this mode, both OKX (Spot) and OKX Futures are supported in Moonbot, and all currencies can be used as collateral.
To switch your account mode on the OKX exchange website, go to the Trade tab, then, for example, select Spot. The trading interface will open. Click on the icon to the right of the text "Spot mode"; a menu for selecting modes will open. Make your selection and click the Switch button at the bottom. -
The Cross/Isolation margin setting on the OKX exchange applies to each individual market, rather than the entire account, unlike, for example, the BitGet exchange. You can only change the margin mode for a market in the Moonbot terminal if there are no open positions or orders on that market.
The main pitfall: OKX does NOT prohibit holding two positions with different margin modes on the same instrument – even two in the same direction (a cross-long and an isolation-long can co-exist, and we have verified this).
Worse still: a ‘close’ order placed in the wrong mode does not close the position, but opens an opposite one.
Conclusion: The RESPONSIBILITY to trade in a single mode at all times and in all circumstances lies with you!
One account OKX = ONE trading mode (either always Cross, or always Isolation), otherwise you will face lost positions and liquidations.