Connect an AI Agent to Binance API
Prerequisites
- Verified Binance account (Full KYC required)
- Python 3.8+
Step 1: Generate API Keys
- Account → API Management → Create API
- Enable: Read Info, Spot Trading, Futures
- Restrict to your server IP
- Save Key and Secret — shown once only
Step 2: Connect with CCXT
pip install ccxt
import ccxt, os
exchange = ccxt.binance({
"apiKey": os.environ["BINANCE_KEY"],
"secret": os.environ["BINANCE_SECRET"],
})
balance = exchange.fetch_balance()
order = exchange.create_market_buy_order("BTC/USDT", 0.001)
Step 3: Use Testnet
exchange.set_sandbox_mode(True)
# Keys from testnet.binance.vision
Or: Activate AI Pro
Binance AI Pro ($9.99/mo beta, 7-day free trial) gives Claude direct access to your Binance account via the OpenClaw ecosystem. One-click activation from the Binance nav bar. Full Binance guide →