Package: python-binance-am11yfork
NoteI am working on a python3 version with async support to remove legacy dependencies and their related issues.I would appreciate if you could try out thefeature/asynciobranch and give your feedback.This is an unofficial Python wrapper for theBinance exchange REST API v1/3. I am in no way affiliated with Binance, use at your own risk.If you came here looking for theBinance exchangeto purchase cryptocurrencies, thengo here. If you want to automate interactions with Binance stick around.If you’re interested in Binance’s new DEX Binance Chain see mypython-binance-chain librarySource codehttps://github.com/sammchardy/python-binanceDocumentationhttps://python-binance.readthedocs.io/en/latest/Binance API Telegramhttps://t.me/binance_api_englishBlog with exampleshttps://sammchardy.github.ioMake sure you update often and check theChangelogfor new features and bug fixes.FeaturesImplementation of all General, Market Data and Account endpoints.Simple handling of authenticationNo need to generate timestamps yourself, the wrapper does it for youResponse exception handlingWebsocket handling with reconnection and multiplexed connectionsSymbol Depth CacheHistorical Kline/Candle fetching functionWithdraw functionalityDeposit addressesMargin TradingFutures TradingSupport other domains (.us, .jp, etc)Quick StartRegister an account with Binance.Generate an API Keyand assign relevant permissions.pipinstallpython-binance-am11yforkfrombinance.clientimportClientclient=Client(api_key,api_secret)# get market depthdepth=client.get_order_book(symbol='BNBBTC')# place a test market buy order, to place an actual order use the create_order functionorder=client.create_test_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(asset='ETH')# get a deposit address for BTCaddress=client.get_deposit_address(asset='BTC')# start aggregated trade websocket for BNBBTCdefprocess_message(msg):print("message type:{}".format(msg['e']))print(msg)# do somethingfrombinance.websocketsimportBinanceSocketManagerbm=BinanceSocketManager(client)bm.start_aggtrade_socket('BNBBTC',process_message)bm.start()# get historical kline data from any date range# fetch 1 minute klines for the last day up until nowklines=client.get_historical_klines("BNBBTC",Client.KLINE_INTERVAL_1MINUTE,"1 day ago UTC")# fetch 30 minute klines for the last month of 2017klines=client.get_historical_klines("ETHBTC",Client.KLINE_INTERVAL_30MINUTE,"1 Dec, 2017","1 Jan, 2018")# fetch weekly klines since it listedklines=client.get_historical_klines("NEOBTC",Client.KLINE_INTERVAL_1WEEK,"1 Jan, 2017")For morecheck out the documentation.DonateIf this library helped you out feel free to donate.ETH: 0xD7a7fDdCfA687073d7cC93E9E51829a727f9fE70LTC: LPC5vw9ajR1YndE1hYVeo3kJ9LdHjcRCUZNEO: AVJB4ZgN7VgSUtArCt94y7ZYT6d5NDfpBoBTC: 1Dknp6L6oRZrHDECRedihPzx2sSfmvEBysOther ExchangesIf you useBinance Chaincheck out mypython-binance-chainlibrary.If you useKucoincheck out mypython-kucoinlibrary.If you useIDEXcheck out mypython-idexlibrary.