python-binance is a Python client library that provides programmatic access to the Binance cryptocurrency exchange through both REST and WebSocket APIs. It serves as a comprehensive toolkit for automated trading, account management, and market data retrieval, enabling developers to build trading bots, portfolio management tools, and data analysis applications that interact directly with the exchange.
The library distinguishes itself through a dual-client architecture that separates synchronous REST calls from persistent WebSocket streams, allowing concurrent execution without blocking. It includes automatic WebSocket reconnection with exponential backoff, a local order book cache built from depth streams, and generator-based historical data streaming for memory-efficient iteration over large datasets. Authentication is handled through HMAC, RSA, or EDDSA signing, and the client supports switching between production, testnet, and regional exchange domains via a single flag.
Beyond core trading operations, the library covers account and portfolio management including balance checks, deposit and withdrawal history, sub-account management, staking positions, and margin trading. It provides extensive market data capabilities such as historical kline retrieval, real-time trade and order book streaming, and ticker data access. Order management includes placement, cancellation, modification, and validation against exchange-defined filters, with support for conditional orders, test orders, and WebSocket-based order submission for lower latency.
The library is distributed as a Python package with documentation covering installation, API reference, and usage examples for both synchronous and asynchronous workflows.