Maintained

python-binance guide

For Binance-only scripts, python-binance remains a convenient, well-documented choice.

Last reviewed · Also known as binance python, binance-connector

Quick answer

python-binance is a widely used community Python wrapper for Binance’s REST and WebSocket APIs, covering spot, margin and futures, with sync and asyncio clients and a testnet flag. Binance also publishes its own official connectors (binance-connector / binance-sdk). For multi-exchange code, CCXT is the usual alternative.

python-binance at a glance

Category
Broker, exchange & data libraries
Language
Python
License
MIT
Does
Market data, Order execution
Markets
Crypto
Best for
Binance-specific bots that need endpoints CCXT does not unify.
In AlgoGP
Use the exported strategy object from your own code

Pick it if

Binance-specific bots that need endpoints CCXT does not unify.

Watch out for

Binance only.

python-binance strengths and limitations

Strengths

  • Broad endpoint coverage.
  • Async client and WebSocket managers.
  • Testnet support.

Limitations

  • Binance only.
  • Unofficial; follows Binance API changes with some lag.

python-binance example

pip install python-binance
Install
from binance.client import Client
client = Client()   # no key needed for public data
klines = client.get_klines(symbol="BTCUSDT", interval=Client.KLINE_INTERVAL_1HOUR, limit=100)
print(klines[-1][:6])
Hourly klines from the public API.

Use python-binance with AlgoGP

AlgoGP does not add python-binance to projects automatically yet, but nothing stops you using them together. Every AlgoGP project exports plain Python with a framework-neutral strategy object, so you can call it from python-binance yourself.

  1. 1

    Design and backtest in AlgoGP

    Describe the idea to the copilot and backtest it on AlgoGP’s normalized history.

  2. 2

    Add any bridge to get the adapter core

    Adding a bridged framework (for example Backtrader) writes frameworks/algogp_bridge.py, whose StrategyBridge.on_bar() returns the orders the strategy wants.

  3. 3

    Call it from python-binance

    Feed python-binance’s bars to StrategyBridge, place the returned orders with python-binance, and report fills back with sync().

python-binance connects to Binance. Each guide shows how to create the API key, which you can store in the project’s Keys & secrets.

python-binance: frequently asked questions

python-binance or CCXT?

python-binance for deep Binance features; CCXT for portability across exchanges.

python-binance alternatives

Independent guide. AlgoGP is not affiliated with python-binance. Features, licenses and maintenance change; check the official documentation. Nothing here is investment advice.

Build a strategy