Skip to content

Binance API python implementation

License

Notifications You must be signed in to change notification settings

viadata/python-binance

Repository files navigation

Welcome to python-binance v0.5.4

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.

Source code
https://github.com/sammchardy/python-binance
Documentation
https://python-binance.readthedocs.io/en/latest/
Binance API Telegram
https://t.me/binance_api_english

Features

  • Implementation of 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
  • Withdraw functionality
  • Deposit addresses

Quick Start

Register an account with Binance.

Generate an API Key and assign relevant permissions.

pip install python-binance
frombinance.clientimportClientclient=Client(api_key, api_secret) # get market depthdepth=client.get_order_book(symbol='BNBBTC') # place market buy orderorder=client.create_order( symbol='BNBBTC', side=Client.SIDE_BUY, type=Client.ORDER_TYPE_MARKET, quantity=100) # get all symbol pricesprices=client.get_all_tickers() # withdraw 100 ETH# check docs for assumptions around withdrawalsfrombinance.exceptionsimportBinanceApiException, BinanceWithdrawExceptiontry: result=client.withdraw( asset='ETH', address='<eth_address>', amount=100) exceptBinanceApiExceptionase: print(e) exceptBinanceWithdrawExceptionase: print(e) else: print("Success") # fetch list of withdrawalswithdraws=client.get_withdraw_history() # fetch list of ETH withdrawalseth_withdraws=client.get_withdraw_history('ETH) # get a deposit addressaddress=client.get_deposit_address('BTC) # start trade websocketdefprocess_message(msg): print("message type:{}".format(msg['e'])) print(msg) # do somethingfrombinance.websocketsimportBinanceSocketManagerbm=BinanceSocketManager(client) bm.start_aggtrade_socket(symbol='BNBBTC') bm.start()

For more check out the documentation.

Donate

If this library helped you out feel free to donate.

  • ETH: 0xD7a7fDdCfA687073d7cC93E9E51829a727f9fE70
  • 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 IDEX check out my python-idex library.

About

Binance API python implementation

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python100.0%