Binance
Installation
pip install binance-python
Usage
Public APIs
You can use specific API clients without authentication. E.g:
from binance.spot import MarketData
client = MarketData()
await client.candles('BTCUSDT', interval='1m', limit=4)
# [Candle(open_time=datetime(...), close_time=datetime(...), open=Decimal('93970.04000000'), ...), ...]
Private API
Easiest is to just use the general client:
from binance import Binance
client = Binance(API_KEY, API_SECRET)
# or client = Binance.env() to load `API_KEY` and `API_SECRET` from environment variables or a .env file
await client.spot.new_order('BTCUSDT', {
'price', 10000, ... # let the type hints guide you
})
Context Manager
To run multiple requests concurrently, I'd recommend using the client as a context manager:
from binance import Binance
client = Binance(API_KEY, API_SECRET)
async with client:
await client.spot.new_order('BTCUSDT', {
'price', 10000, ...
})
await client.spot.new_order('ETHUSDT', {
'price', 2000, ...
})
Supported APIs
Spot
General
Market Data
- Order Book
- Recent Trades
- Old Trades
- Aggregated Trades
- Candles
- UI Candles
- Average Price
- Last 24h Price Change Statistics
- Last Day Price Change Statistics
- Current Price
-
Symbol Order Book Tickerunnecessary, use Order Book instead - Window Price Change Statistics
Trading
- New Order
- Test New Order
- Query Order
- Cancel Order
- Cancel Open Orders
- Replace Order
- Query Open Orders
- Query All Orders
- New OCO Order
- New OTO Order
- New OTOCO Order
- Cancel Order List
-
Query Order Listsupport unplanned - Query
All Order Listssupport unplanned - Query
Open Order Listssupport unplanned -
New SOR Ordersupport unplanned -
Test SOR Ordersupport unplanned
Account
- Information
- List Trades
-
Query Unfilled Order Countsupport unplanned -
Query Prevented Matchessupport unplanned -
Query Allocationssupport unplanned -
Query Commission Ratessupport unplanned
Margin
- Market Data
- Trading
- Borrow and Repay
- Account
- Transfer
Simple Earn
Account
- Account Summary
- List Flexible Products
- List Locked Products
- Flexible Product Position
- Locked Product Position
- Flexible Product Left Quota
- Locked Product Left Quota
Earn
- Subscribe Flexible Product
-
Subscribe Locked Productsupport unplanned - Redeem Flexible Product
-
Redeem Locked Productsupport unplanned -
Set Flexible Auto-Subscribesupport unplanned -
Set Locked Auto-Subscribesupport unplanned - Flexible Subscription Preview
-
Locked Subscription Previewsupport unplanned -
Set Locked Redeem Optionsupport unplanned
History support unplanned
Wallet
Capital
- All Coins Info
- Withdraw
- Withdraw History
- Withdraw Address List
- Deposit History
- Deposit Address
- Deposit Address List
-
One-Click Depositsupport unplanned
Asset support unplanned
Account support unplanned
Travel Rule support unplanned
Metadata
Release files for binance-python 0.2.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| binance_python-0.2.9.tar.gz | 24.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| binance_python-0.2.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 77.2 kB
Release files / binance_python-0.2.9.tar.gz
| Download URL | binance_python-0.2.9.tar.gz |
|---|---|
| Size | 24.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
64168650bceda69a86a14afbae1ee83f65da652e51469ed02c5a1506060a6c96
|
|
BLAKE2b-256 checksum How to use checksums |
fb7764db206a73eac558bab7187dba9936e9cafbe67c4abeb1889d1d6e78d9cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.10
|
Release files / binance_python-0.2.9-py3-none-any.whl
| Download URL | binance_python-0.2.9-py3-none-any.whl |
|---|---|
| Size | 53.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4b90a1a512821b1b2991bd8a4d946f1626beff53215e0a02612d6fa9fa0e9568
|
|
BLAKE2b-256 checksum How to use checksums |
266f86c1ed25b4b6ef1ded550103070ab864eb460d3d8bc01469a930101b7c2e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.10
|