Crypto, the big picture
How to Set Up Exchange API Keys Safely in 2026: OKX, Bybit, Bitget and Binance
A trading bot's API key should have read and trade permissions only, never withdrawals, be bound to a fixed IP, and live in its own sub-account. OKX, Bybit and Binance all expire or delete keys that have no IP bound, each on a different schedule.
Kelvin Wang · · 7 min read
These rules come from the four exchanges’ official API docs and help pages, checked on 7 November 2026. These rules change, so check the official page again before you set anything up.
API key, secret and passphrase
- API key. The public identifier sent with every request, so the exchange knows which key is calling.
- Secret key. The private string used to sign requests. The exchange shows it once, at creation. If it leaks, someone else can trade with your permissions.
- Passphrase. OKX and Bitget ask you to set one when you create the key, and every request must include it. OKX stores only a salted hash, so if you lose it you have to create a new key. Bitget’s passphrase can’t be changed once set; if you forget it, you delete the key and create a new one. Binance and Bybit don’t use a passphrase.
Binance and Bybit also accept self-generated asymmetric keys. You generate an Ed25519 or RSA key pair on your own machine and give the exchange only the public key; the private key never leaves your machine. With a system-generated HMAC key, the exchange holds the same secret you do.
My own bots use Ed25519 keys.
The four exchanges compared
| Item | OKX | Bybit | Bitget | Binance |
|---|---|---|---|---|
| Where to create | The "My API" page on the website (/account/my-api) | On the Bybit website; mainnet and testnet keys are created separately | Website personal center → API Management; since August 2023 the app can't create, edit or delete keys | Profile → Account → API Management; in the app, More → Others → API Management |
| Permissions | Read, Trade, Withdraw; Trade also covers funding transfers | Read-only or read-write, then categories such as contract, spot and Wallet (transfers); Withdraw exists only on the master account | Read-only, trade, transfer, withdraw | Reading, trading, futures, withdrawals and others, depending on which products the account has enabled |
| IP whitelist | Up to 20 IPs per key; IPv4, IPv6 and ranges | Several IPs, comma-separated | Bitget recommends no more than 10 IPs per key; withdrawals only work from a whitelisted IP | IPv4 restriction is required for withdrawals; a system-generated HMAC key without an IP restriction can only read |
| Sub-accounts | Sub-account keys can only have Read and Trade; sub-accounts can't withdraw | The master account creates sub-accounts and their keys; Withdraw is not among sub-account permissions | The master account must first grant the sub-account API management permission, and can view, edit or delete its keys at any time | Sub-accounts can't withdraw; a regular user can open 5 sub-accounts, with higher limits by VIP level and account type |
| Rate limits (headline) | Per endpoint; at most 1,000 new and amended orders per 2 seconds per sub-account | 600 requests per 5 seconds per IP; order endpoints roughly 10 to 20 per second | 6,000 requests per minute per IP; public endpoints 20 per second | Spot: 6,000 weight per minute per IP and 100 orders per 10 seconds; futures: 2,400 weight per minute |
Checked 2026-11-07. Sources at the end: OKX API docs; Bybit API docs (create sub UID API key, API key info, rate limits); Bitget UTA and classic API docs, API trading guideline and app key-management announcement; Binance's API key guide, security blog and sub-account FAQ, plus the rateLimits returned by Binance's spot and futures exchangeInfo.
Details that don’t fit in the table:
- OKX counts a key as used only when it calls an endpoint that needs key authentication. On WebSocket, only the login counts. Demo trading keys don’t expire.
- Bybit’s API key info endpoint returns
deadlineDayandexpiredAt. They are filled in only for keys with no IP bound or after a password change, so you can build an expiry reminder from them. Going over Bybit’s IP limit returns a 403; you have to close all sessions and wait at least 10 minutes. - Binance’s weight limits apply to the IP, not the key. Keep sending after a 429 and you get a 418 and an IP ban lasting from 2 minutes to 3 days. Since 30 January 2023, a system-generated key without an IP restriction can only read.
- Binance’s order-count limits apply to the account and are shared by all its keys. Several bots on one account eat each other’s quota, which is one more reason to split them into sub-accounts.
Six security rules
Never enable withdrawals
A bot only needs to read data and place orders. With withdrawals on, whoever gets the key can simply withdraw your coins. Binance won’t enable withdrawals without an IP restriction, Bitget only allows withdrawals from whitelisted IPs, and sub-accounts at OKX and Binance can’t withdraw at all. All of this is there so that a leaked key can’t move money out.
Each of my bots has read and futures trading only, with no transfers.
Bind an IP
If your bot runs on a machine with a fixed IP, bind that IP. A leaked key called from anywhere else is then rejected. The expiry rules at OKX, Bybit and Binance also apply only to keys without an IP: at OKX, keys with trade or withdraw permission expire after 14 days of inactivity; at Bybit, keys become invalid after 90 days, or 7 days after an account password change; at Binance, keys are deleted after 30 days of inactivity. Home connections change IP, so a bot is better off on a host with a fixed address.
I haven’t had a bot stop because a key expired or an IP changed. My bots run on AWS, and the whitelist uses a fixed IP.
One sub-account per bot
Sub-accounts separate funds and permissions. If one bot’s key is compromised, the loss is limited to that sub-account’s balance. Rate limits are counted separately too, and OKX even has an order limit at the sub-account level. Don’t give the master account’s key to any bot.
I split mine by exchange: each exchange gets its own sub-account for the bots.
Keep secrets in environment variables or a secrets manager
Secrets don’t belong in code, in git, in screenshots, in chat logs or in support tickets. Binance’s security article also recommends storing key data encrypted or in a trusted secrets manager, and warns that some third-party libraries are built to steal API keys.
I keep my keys in AWS’s secrets management service.
Rotate keys
Practise the swap before you need it: create the new key, update the bot, confirm orders go through on the new key, then delete the old one. Bitget’s passphrase can’t be changed, so rotating there means a whole new key. Bybit keys with no IP bound become invalid after 90 days anyway, which forces a rotation; choosing “no IP restriction” again on the API management page pushes the expiry to 90 days from then, with the same key and secret.
Revoke keys as soon as a third-party tool shuts down or has an incident
Delete the key the same day for any tool you’ve stopped using, any platform that announces it’s closing, and any service reported to have leaked data. Deleting a key doesn’t touch the assets in your account; you can create a new one when you need it.
The 3Commas case: no withdrawal permission, assets moved anyway
3Commas is a trading bot platform. Users hand it their exchange API keys so it can place orders for them.
In October 2022, fake copies of the 3Commas site collected users’ keys, which were then used to trade on FTX’s DMG pairs. The Block reported that on-chain data put the total stolen at about $6 million, and FTX announced a one-time compensation. 3Commas said at the time the problem did not lie with its own systems.
In December, an anonymous user published about 100,000 API keys on Twitter, mostly belonging to Binance and KuCoin users, and said this was 10% of what they held. Binance CEO Changpeng Zhao said he was reasonably sure there were widespread API key leaks from 3Commas and told anyone who had ever entered a key into 3Commas to disable it immediately. On 28 December, 3Commas CEO Yuriy Sorokin confirmed the data in the files was real and asked Binance, KuCoin and other exchanges to revoke every key connected to 3Commas. He said no evidence of an inside job had been found. Exchanges won’t necessarily cover losses from a leaked key: before 3Commas confirmed the leak, Binance refused to reimburse a user who blamed their losses on a leaked 3Commas-linked key. The week before the confirmation, traders had reported losses of about $22 million tied to the service.
What you take on when you hand a key to a third-party tool
TradingView webhooks don’t need your exchange key. When an alert fires, TradingView sends the message as an HTTP POST to a URL you choose; the server receiving that webhook is what holds the key and places the order. If that server is yours, the key stays with you. If it’s a third-party relay service, the key sits with them. TradingView also says not to put login credentials or passwords in the webhook body. Webhooks require two-factor authentication, only use ports 80 and 443, and come from four published IP addresses, so a self-hosted server can accept only those.
Copy-trading bots and cloud grid bots work the same way: your key lives in their database. If they get breached, have an employee go bad or go out of business, there’s nothing you can do about it. Before handing over a key, ask:
- Does the service publish fixed server IPs you can whitelist? If it does, a stolen key can only be used from their servers.
- Does it ask only for read and trade? Skip any tool that asks for withdrawal or transfer permissions.
- Is the key on a dedicated sub-account holding only what you’re willing to risk?
- Do you know where to delete the key if the tool shuts down or has an incident?
Data sites such as CoinGlass have API keys too. That key comes from your CoinGlass account and goes in a CG-API-KEY header to query data. It’s a separate thing from an exchange key and can’t touch your assets.
For what to do when an exchange itself is hacked, see Exchange hacked? 5 steps. Reviews of the four exchanges (in Chinese): OKX, Bybit, Bitget, Binance.
If you want to open an OKX account, the fee discount details are on the OKX page (in Chinese).
Sources
- 1. OKX API v5 docs (REST authentication, API key security, sub-accounts, rate limits, error codes)
- 2. Bybit API: Create Sub UID API Key
- 3. Bybit API: Get API Key Information
- 4. Bybit API: Rate Limit Rules
- 5. Bybit API: Integration Guidance
- 6. Bitget API: UTA Quick Start
- 7. Bitget API: Classic REST API
- 8. Bitget API Trading Guideline
- 9. Bitget Announcement on the suspension of API key management support on the app
- 10. Bybit API: FAQ
- 11. How to Create API Keys on Binance
- 12. How to Use an API Key Securely: 5 Tips From Binance
- 13. Binance's API Key Deletion Policy
- 14. Binance Sub-Account Functions and FAQ
- 15. Binance Spot API: Rate limits
- 16. Binance WebSocket API: Rate limits
- 17. Binance spot exchangeInfo (rateLimits)
- 18. Binance futures exchangeInfo (rateLimits)
- 19. FTX will compensate phishing victims up to $6 million, says Sam Bankman-Fried
- 20. Crypto trading service 3Commas confirms massive API key leak
- 21. 3Commas CEO confirms API key leak following warning from CZ
- 22. About webhooks
- 23. CoinGlass API: Authentication
Kelvin Wang
Electrical engineer building tools with AI agents, sharing hands-on notes on engineering and investing.
More about me