Skip to content
Rulemancer Blog Blog & Docs
Guides

Trade-only API keys: connect an exchange without handing over your funds

Trade-only API keys: connect an exchange without handing over your funds

An exchange API key is a password for a program. When you connect an exchange to a trading bot, the bot needs a key that can read balances and place orders — and, ideally, nothing else. The permission set you choose at creation time, not the bot’s code, decides whether a mistake can drain an account. Getting that set right takes two minutes and is the single most useful security step in automated trading.

What a key is allowed to do

Exchanges split API permissions into a few switches. The names differ slightly, the intent does not:

Permission What it enables Needed for a bot?
Read Balances, open orders, trade history Yes — the bot must know what it holds
Spot trade Placing and cancelling orders Yes — this is the whole point
Withdraw Moving funds off the exchange No
Transfer / internal Moving funds between wallets No

A key that cannot withdraw cannot empty your account, whatever happens to the bot, the server or the key itself. That single restriction turns a catastrophic risk into an inconvenience.

Three checks before you save the key

  1. Withdrawals off. Create the key with trading enabled and withdrawals disabled. If your exchange asks for a separate “enable withdrawals” step with extra verification, leave it alone.
  2. IP allowlist on. Most exchanges let you bind a key to one or a few IP addresses. Bind it to the server that runs your bots; a stolen key used from anywhere else simply fails.
  3. Label it. Name the key after the platform and the date, so a future you can tell which key belongs where before revoking it.

Rulemancer refuses keys that can withdraw, and it verifies each key against the exchange’s real API before storing it. The check exists because a bot that never needs to move money should never be able to.

Rotation is not paranoia

Keys live longer than projects do. A rotation every few months costs one minute and removes the entire class of “old key I forgot about” incidents. The routine is the same everywhere: create the new key, add it to the bot, confirm the next trade fills, then delete the old one. Deleting first and creating later leaves you with a bot that silently cannot trade.

Do the same whenever a laptop, a password manager or a hosting account changes hands. A key is only as secret as the least protected place it was ever pasted.

If a key leaks, act in this order

  1. Revoke on the exchange first, not in the bot. Revocation at the source is immediate; everything else is tidying up.
  2. Cancel open orders that the key placed, if the exchange still shows any.
  3. Disconnect the key in the platform so the bot stops retrying.
  4. Check the trade history for orders you did not write.
  5. Create a new key with the same restricted permissions and reconnect.

Because the key could not withdraw, the worst case is unwanted trades inside the balance you had allocated — bad, bounded, and recoverable. That bound is exactly what the permission set buys you.

What the platform stores

Keys are encrypted at rest, never displayed again after saving, and never written to logs. The bot uses them to read balances and place orders, which is why the encryption key of the installation matters: changing it makes stored keys unreadable and forces every user to reconnect. Treat that value as part of your security perimeter, not as a configuration detail.

For the wider picture on API security, the OWASP API Security project is a good plain-language reference; exchange-specific key settings are documented in each venue’s API guide, such as the Binance Spot API documentation.

Frequently asked questions

Can a trade-only key lose money?

Yes — it can place bad trades within the balance you leave on the exchange. It cannot move funds out to another address. Keeping only your working balance on an exchange limits that exposure further.

Do I need a separate key per bot?

One key per exchange is usually enough, because the limits live in the bot’s risk settings rather than in the key. Separate keys per bot make revocation more surgical if you run very different strategies.

What happens if I disable the key on the exchange?

Live orders fail immediately and the bot reports the error; paper bots keep running because they use public data. Reconnect a valid key to resume live trading.