Is It Safe to Give a Trading Bot Your Exchange API Keys?
What an exchange API key actually grants, why “trade-only” keys are weaker than they sound, how to limit the damage if you still use one, and what a bot looks like when it never needs a key at all.
Table of Contents
Every bot platform that connects to an exchange asks the same thing: create an API key, paste it here. Most add “withdrawals disabled, so it’s safe”. That statement is true as far as it goes and misleading in what it leaves out. This article goes through what a key grants, how keys get compromised, how to reduce the damage if you use one anyway, and what the alternative looks like.
What an API Key Actually Grants
An API key is a long-lived credential that lets software act as you on the exchange. Exchanges let you choose a scope when you create one, usually some mix of read, trade and withdraw, sometimes narrowed to specific markets or a list of IP addresses. The key is checked by the exchange’s servers on each request. Two consequences follow. The scope is only as strong as the exchange’s implementation, and anyone with the key has the full scope until you delete the key: there is no second factor on an API call.
| Scope | What it allows | What a thief can do with it |
|---|---|---|
| Read | Balances, orders, history | Learn exactly what you hold and when you trade |
| Trade | Place and cancel orders | Sell your holdings into anything the key may trade; front-run your own orders |
| Withdraw | Send funds out | Empty the account |
Why “Trade-Only” Is Weaker Than It Sounds
A trade-only key cannot send your coins to an attacker’s address. It can place market orders. If the key may trade a thin market, an attacker can sit on the other side of it and buy your whole balance at a price they set; if it may trade a token that goes to zero, selling you into it has the same effect. Exchanges differ in whether a key can be restricted to specific markets and whether sub-accounts are available. Where they are, use them. Where they are not, a trade-only key is withdrawal by another route, with the exchange’s order book as the courier.
The second weakness is structural. The key sits in two places you do not control: the exchange’s authentication system and the bot platform’s database. A breach of either exposes it. Your own care with the key does not change that.
Where Keys Leak
- The bot platform. It must store the key in a form it can use, which means the key, or something equivalent, is decryptable on its servers. A breach, an insider, or a bug in an export endpoint exposes every customer’s keys at once.
- Your own machine. Keys pasted into a browser, saved in a notes app, or kept in a config file are readable by malware with ordinary user permissions.
- Phishing. A page that looks like the bot platform and asks you to “reconnect your exchange” collects the key directly.
- Reuse. One key shared between a portfolio tracker, a tax tool and a bot has three places to leak from and one blast radius.
If You Use a Key Anyway: How to Limit the Damage
- Trade-only, never withdraw. Confirm it in the exchange’s key settings, not in the bot’s UI.
- IP whitelist the platform’s published addresses, so a leaked key is useless from anywhere else.
- Restrict markets to the pairs the bot trades, if the exchange supports it; otherwise use a sub-account that holds only those assets.
- Fund the sub-account with what the bot needs, not your whole balance. The key’s blast radius is the account it can see.
- One key per service. Delete keys for services you stopped using.
- Rotate on a schedule and immediately after any news of a breach at the platform.
- Watch the account with the exchange’s own alerts, not only the bot’s dashboard: a bot that is misbehaving will not report itself.
Done properly, this reduces an API-key setup to a manageable risk for a balance you can afford to see mistraded. It does not reduce the exchange’s own custody risk at all, which is the part of the arrangement that the 2022 bankruptcies were about.
What a Bot Looks Like Without a Key
The alternative is to give the bot a permission rather than a password. A smart account such as a Safe can install an ERC-7579 Smart Sessions module and store, in the account’s own contract, exactly what a session key may call. The chain checks the permission on every operation. In DCA Bot’s case your wallet is the Safe’s only owner, and each bot session is limited to one swap direction of one pair you allowed: it may approve the Uniswap V3 router for the token it sells, call exactInputSingle with that input token, that output token and your Safe as the recipient, and transfer the platform fee to the fee wallet. Nothing else validates: no transfers elsewhere, no other tokens, no ETH, no owner changes.
| Exchange API key | On-chain session | |
|---|---|---|
| Who enforces the scope | The exchange’s software | The Safe contract on-chain |
| Can it withdraw? | Only if the scope allows; cannot be verified from outside | No; the permission does not include transfers to anyone but the fee wallet |
| Can it swap into any token? | Any market the key may trade | Only the pinned output token of each allowed pair |
| Where the funds are | On the exchange | In a Safe your wallet owns |
| Revocation | Delete the key on the exchange | One wallet signature; works even if the bot’s site is gone |
| Can you audit it? | Trust the platform and the exchange | Read the session’s actions on-chain |
The mechanics are described in Smart Sessions explained and how a non-custodial bot works.
What the Keyless Model Does Not Fix
A session that can swap can swap badly. The minimum output on each DCA Bot swap is computed by the server, so if the server were compromised an attacker could make unfavourable swaps of your allowed pairs inside your Safe, losing you money to price impact or a sandwich without ever taking anything out. The fee transfer is pinned to the fee wallet but its amount is not capped on-chain yet, so a compromised server could move more than the fee to that wallet (whose key is not on the server). Both are listed in the threat model, with what is planned. Beyond the bot, you carry self-custody risk: the wallet that owns the Safe is the only thing that can withdraw from it. The keyless model moves the trust from “the platform and the exchange will not misuse a password” to “the contract does what it says and I keep my wallet safe”. That is a better place for the trust to sit, not an absence of it.
How to Check Instead of Trust
The point of an on-chain permission is that you do not have to believe any of the above. Paste a Safe address into the Verify page and it reads, from the chain, who owns the Safe and its validator, which modules are installed, and what each session may call, flagging anything outside a pinned swap, a router approval or the fee transfer. The proof page explains the mechanism in one screen, and the security page lists the contract addresses and the exact calls to make on a block explorer. If you want to see the model before putting a Safe behind it, a demo on the try page trades paper money on live prices with no key and no deposit.
Frequently Asked Questions
Can a trade-only API key steal my funds?
Not by withdrawing. It can sell everything you hold into a worthless token or into a thin market where a counterparty of the attacker’s choosing is waiting on the other side, which has the same effect for you. Whether an exchange lets a trade-only key do that depends on which markets the key may trade and whether you restricted it.
Is IP whitelisting enough?
It helps a lot against a leaked key being used from elsewhere. It does nothing if the platform that legitimately holds the key is itself compromised, because its servers are the whitelisted IPs.
Does a non-custodial bot mean zero risk?
No. In DCA Bot’s case the server computes the minimum output on each swap, so a compromised server could make bad swaps of your allowed pairs inside your Safe, and the fee transfer is pinned to the fee wallet but its amount is not capped on-chain yet. Those are documented in the threat model. What it removes is the ability to withdraw, to swap into arbitrary tokens, and to change who owns the account.
How do I verify what a bot session can do on my Safe?
Paste the Safe address into the Verify page. It reads the owners, the validator owner, the installed modules and every session, and flags any session action that is not a pinned swap of one pair back into the Safe, a router approval, or the fee transfer.
Ready to automate your crypto trading?
Set up DCA, grid, or limit-order strategies on Uniswap V3 for Arbitrum and Base — from your own Safe, with a free demo to start.