Claude Code + Binance API: Complete Setup Guide

beginner 30 min · · By Alpha Guy · claude-code binance

What You’ll Set Up

By the end of this guide, you’ll have:

  • A Binance account with API keys configured for trading
  • Claude Code installed and ready to use
  • A Python environment with the CCXT library
  • A working script that fetches your account balance

Prerequisites

  • A computer with Python 3.10+ installed
  • A Binance account (we’ll show you how to get API keys)

Step 1: Get Your Binance API Keys

  1. Log into your Binance account
  2. Navigate to AccountAPI Management (see the Binance API documentation for full details)
  3. Click “Create API” and choose “System Generated”
  4. Name it something like trading-bot-dev

Important: Only enable “Enable Spot & Margin Trading”. Do NOT enable withdrawals.

Save your API key and secret somewhere safe — you won’t be able to see the secret again.

Step 2: Install Claude Code

Open your terminal and install Claude Code:

npm install -g @anthropic-ai/claude-code

Verify the installation:

claude --version

Step 3: Set Up Your Python Project

Create a new project directory and set up a virtual environment:

mkdir my-trading-bot && cd my-trading-bot
python3 -m venv venv
source venv/bin/activate
pip install ccxt python-dotenv

Create a .env file for your API keys:

BINANCE_API_KEY=your_api_key_here
BINANCE_API_SECRET=your_secret_here

Step 4: Your First API Call

Ask Claude Code to generate a simple script:

claude "Write a Python script that uses ccxt to connect to Binance
and fetch my USDT balance. Use python-dotenv to load API keys
from a .env file."

Claude Code will generate something like:

import ccxt
import os
from dotenv import load_dotenv

load_dotenv()

exchange = ccxt.binance({
    'apiKey': os.getenv('BINANCE_API_KEY'),
    'secret': os.getenv('BINANCE_API_SECRET'),
})

balance = exchange.fetch_balance()
usdt = balance['total'].get('USDT', 0)
print(f"USDT Balance: {usdt}")

Run it:

python balance.py

If you see your USDT balance printed, everything is working.

Next Steps

Disclaimer: This article is for educational purposes only and is not financial advice. Trading cryptocurrencies involves substantial risk of loss. Past performance does not guarantee future results. Always do your own research before making any trading decisions. Read full disclaimer →
Alpha Guy
Alpha Guy

Founder of VibeTradingLab. Ex-Goldman Sachs engineer, 2025 Binance Top 1% Trader. Writes about using AI tools to build trading systems that actually work. Currently nomading between Bali, Dubai, and the Mediterranean.

Got stuck? Have questions?

Join our Telegram group to ask questions, share your bots, and connect with other AI traders.

Join Telegram