Setup
Binance API keys for a bot (safely)
Most blown accounts in this niche are not “bad strategy.” They are keys that can withdraw, keys sitting in a public repo, or keys with no IP lock. Do this part slowly.
Never enable withdrawals on a bot key. If a key can move coins off the exchange, a leaked file becomes a drained account. No strategy needs withdraw permission.
What the bot actually needs
- Read account info (balances, open orders)
- Create and cancel spot orders
- Futures only if you truly understand liquidation
You do not need withdrawals, internal transfers, or extras you will not use.
Create the key on Binance
- Log in on the official site. Do not follow a search-ad lookalike.
- Open API Management.
- Create a new API key. Name it something dull like vps-bot-spot-readonly-first.
- Complete 2FA. Store the secret key once. You will not see it again.
- Edit restrictions immediately.
Lock it down
Do
- Disable withdrawals
- Restrict to Spot only until paper trading is done
- Enable IP access restriction to the VPS IP
- Store keys in .env on the server only
Do not
- Put keys in screenshots or Discord
- Commit keys to GitHub
- Reuse one key across laptops, phones, and the VPS
- Leave unrestricted IP on a live key
IP allowlist
Put only the VPS public IPv4 on the key. If you rebuild the server and the IP changes, auth errors mean the restriction is working. Update the allowlist. Do not turn it off “for a minute.”
BINANCE_API_KEY= BINANCE_API_SECRET= BINANCE_BASE_URL=https://api.binance.com
On the server: chmod 600 .env. Do not hardcode secrets in Python.
If a key leaks
- Delete the key in Binance first. Do not debug first.
- Rotate to a new key with a new secret.
- Check withdrawal history and device logins.
- Assume any copy of .env in email or chat is burned.
Get the full walkthrough
The paid guide includes the source, config template, and deploy script. 50% off: $19.99 (was $39.99). One-time.
Get the ebook — $19.99Educational product. Trading can lose money. Not financial advice.