Skip to content
Binance API python implementation
Branch: master
Clone or download
#5 Compare This branch is 1 commit ahead, 69 commits behind sammchardy:master.
Latest commit fdf0277 Jun 21, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
binance Allow for millisecond timestamp values to be passed to get_historical… Apr 27, 2018
docs Update to v0.6.9 Apr 27, 2018
tests Removed whitespaces from blank line, and added whitespace between lis… Mar 22, 2018
.gitignore chore(gitignore): Add some dev artifacts to .gitignore Jan 13, 2018
.travis.yml Install test requirements first Oct 25, 2017
LICENSE Initial commit Aug 14, 2017
PYPIREADME.rst Update to v0.6.9 Apr 27, 2018
README.rst Update to v0.6.9 Apr 27, 2018
requirements.txt Add dateparser dependency Jan 9, 2018
setup.cfg Attempt to ignore pep8 line to long error Aug 25, 2017 Update to v0.6.9 Apr 27, 2018
test-requirements.txt Update pytest version Nov 9, 2017
tox.ini Validate and examples with flake8 Jan 23, 2018


Welcome to python-binance v0.6.9

This is an unofficial Python wrapper for the Binance exchange REST API v1/3. I am in no way affiliated with Binance, use at your own risk.

If you came here looking for the Binance exchange to purchase cryptocurrencies, then go here. If you want to automate interactions with Binance stick around.

Source code
Binance API Telegram
Blog with examples

Make sure you update often and check the Changelog for new features and bug fixes.


  • Implementation of all General, Market Data and Account endpoints.
  • Simple handling of authentication
  • No need to generate timestamps yourself, the wrapper does it for you
  • Response exception handling
  • Websocket handling with reconnection and multiplexed connections
  • Symbol Depth Cache
  • Historical Kline/Candle fetching function
  • Withdraw functionality
  • Deposit addresses

Quick Start

Register an account with Binance.

Generate an API Key and assign relevant permissions.

pip install python-binance
from binance.client import Client
client = Client(api_key, api_secret)

# get market depth
depth = client.get_order_book(symbol='BNBBTC')

# place a test market buy order, to place an actual order use the create_order function
order = client.create_test_order(

# get all symbol prices
prices = client.get_all_tickers()

# withdraw 100 ETH
# check docs for assumptions around withdrawals
from binance.exceptions import BinanceAPIException, BinanceWithdrawException
    result = client.withdraw(
except BinanceAPIException as e:
except BinanceWithdrawException as e:

# fetch list of withdrawals
withdraws = client.get_withdraw_history()

# fetch list of ETH withdrawals
eth_withdraws = client.get_withdraw_history(asset='ETH')

# get a deposit address for BTC
address = client.get_deposit_address(asset='BTC')

# start aggregated trade websocket for BNBBTC
def process_message(msg):
    print("message type: {}".format(msg['e']))
    # do something

from binance.websockets import BinanceSocketManager
bm = BinanceSocketManager(client)
bm.start_aggtrade_socket('BNBBTC', process_message)

# get historical kline data from any date range

# fetch 1 minute klines for the last day up until now
klines = client.get_historical_klines("BNBBTC", Client.KLINE_INTERVAL_1MINUTE, "1 day ago UTC")

# fetch 30 minute klines for the last month of 2017
klines = client.get_historical_klines("ETHBTC", Client.KLINE_INTERVAL_30MINUTE, "1 Dec, 2017", "1 Jan, 2018")

# fetch weekly klines since it listed
klines = client.get_historical_klines("NEOBTC", Client.KLINE_INTERVAL_1WEEK, "1 Jan, 2017")

For more check out the documentation.


If this library helped you out feel free to donate.

  • ETH: 0xD7a7fDdCfA687073d7cC93E9E51829a727f9fE70
  • LTC: LPC5vw9ajR1YndE1hYVeo3kJ9LdHjcRCUZ
  • NEO: AVJB4ZgN7VgSUtArCt94y7ZYT6d5NDfpBo
  • BTC: 1Dknp6L6oRZrHDECRedihPzx2sSfmvEBys

Other Exchanges

If you use Quoinex or Qryptos check out my python-quoine library.

If you use Kucoin check out my python-kucoin library.

If you use Allcoin check out my python-allucoin library.

If you use IDEX check out my python-idex library.

If you use BigONE check out my python-bigone library.

You can’t perform that action at this time.