{
"info": {
"author": "Wally Yu",
"author_email": "",
"bugtrack_url": null,
"classifiers": [],
"description": "## Binance DEX / Binance Chain Python Package\n
\n\n\n## Introudction:\nThis Python package develop based on [Binance Chain official doc](https://docs.binance.org/) and tested all functionalities on test-net as well as main-net.\n\n#### Dex Links:\n - Test-net: https://testnet.binance.org/\n - Main-net: https://www.binance.org\n\nAccording to official doc, ways to connect to Binance DEX are:\n - REST API\n - CLI\n - Web Socket\n - Node RPC\n\nThis python package will provide all methods available as from binance official document except cli:\n- [x] REST API\n- [ ] CLI\n- [x] WebSocket\n- [x] Node NRPC\n\n## Environment:\nDue to time limitation, we didn't test different python version + os environment combinations, below are what we tested so far:\n- [x] Python3.5 + MacOs\n- [x] Python3.5 + Windows10\n\nwe are not sure if there would be any compatibility issues for python2.7, let us know if you encounter any issue.\n\nBTW, we do suggest to use Virtual Environment.\n\n## Python SDK Sample Usage:\n\n#### Install package:\n\n```\npip install binance-dex\n```\n - Notes: If you are working on Windows platform, compiling tools `Microsoft Visual C++ 14.0` is required.\n\n#### Full Code Example\nFind full Sample Usage from [code_examples.py](https://github.com/wally-yu/binance-dex/blob/master/sample.py)\n\n---\n\n#### Code Examples Sector by Sector\n\n#### - API Sample Usage\n```\nfrom binance_dex.api import BinanceChainClient\n\n# create API Client instance\napi_client = BinanceChainClient(is_test_net=True)\n\n# call corresponding methods\nprint(api_client.get_block_time())\n\n```\nSample return:\n\n```\n{'status': True, 'result': {'ap_time': '2019-04-06T04:43:48Z', 'block_time': '2019-04-06T04:43:47Z'}}\n```\n[++Find more API information by clicking this link++](https://github.com/wally-yu/binance-dex/blob/master/README_API.md)\n\n\n---\n\n\n#### - Crypto Sample Usage\n\n```\nfrom binance_dex.crypto import BinanceChainCrypto\n\n# Create crypto instance\ncrypto_instance = BinanceChainCrypto(is_test_net=True)\n\n# Generate Mnemonic words\nmnemonic_words = crypto_instance.generate_mnemonic()\nprint(\"Generating Mnemonic Words: \")\nprint(mnemonic_words)\n\n# Generate Private Key, Public Address and mnemonic\nkey = crypto_instance.generate_key()\nprint('Generating Private Key / Public Key / Mnemonic words: ')\nprint(key)\n```\nSample return:\n\n```\nGenerating Mnemonic Words: \nearly solid bronze civil version orange prize curve glory cricket ticket already weekend home early buyer zebra olive melody enrich park jeans apart tower\n\nGenerating Private Key / Public Key / Mnemonic words: \n{'private_key': '65dba225a6965020ff7aae6efc8b9494cbf52bea36e44341d471a7b4b8207e1a', 'public_address': 'tbnb1uvjsrw2pstxqwk45n8k6ke53yw8fsegjery2en', 'mnemonic': 'allow adult frown ivory coffee inhale calm assist galaxy indoor credit oyster tower exclude popular veteran first hint flag boost right zone clown flower'}\n\n```\n[++Find more Crypto information by clicking this link++](https://github.com/wally-yu/binance-dex/blob/master/README_Crypto.md)\n\n\n---\n\n#### - Socket Sample Usage\n\n```\nfrom binance_dex.sockets import BinanceChainSocket\n\n# --- Notice: Need to provide customized Call Back function to handle socket return data ---\n\n# Sample of Customized Callback function to handle received data\ndef customized_call_back(ws, received_message):\n ''' Simply print out '''\n print('----- Customized handler -----')\n print(str(received_message))\n\n\n# Create Socket Instance\nsocket_instance = BinanceChainSocket(IS_TEST_NET)\n\n# 24hr Ticker statistics for a single symbol, push every second\nsocket_instance.fetch_ticker_streams(trading_pair='100K-9BC_BNB',\n is_full_data=True,\n one_off=False, # long lived connection\n callback_function=customized_call_back)\n```\nSample return:\n\n```\n----- Customized handler -----\n{\"stream\":\"ticker\",\"data\":{\"e\":\"24hrTicker\",\"E\":1555687041,\"s\":\"100K-9BC_BNB\",\"p\":\"0.00000000\",\"P\":\"0.00000000\",\"w\":\"49999.00000000\",\"x\":\"49999.00000000\",\"c\":\"49999.00000000\",\"Q\":\"0.00009820\",\"b\":\"0.00000000\",\"B\":\"0.00000000\",\"a\":\"4700.00000000\",\"A\":\"0.13197840\",\"o\":\"49999.00000000\",\"h\":\"49999.00000000\",\"l\":\"49999.00000000\",\"v\":\"0.00000000\",\"q\":\"0.00000000\",\"O\":1555600601881,\"C\":1555687001881,\"F\":\"8274485-0\",\"L\":\"8274485-0\",\"n\":0}}\n\n----- Customized handler -----\n{\"stream\":\"ticker\",\"data\":{\"e\":\"24hrTicker\",\"E\":1555687042,\"s\":\"100K-9BC_BNB\",\"p\":\"0.00000000\",\"P\":\"0.00000000\",\"w\":\"49999.00000000\",\"x\":\"49999.00000000\",\"c\":\"49999.00000000\",\"Q\":\"0.00009820\",\"b\":\"0.00000000\",\"B\":\"0.00000000\",\"a\":\"4700.00000000\",\"A\":\"0.13197840\",\"o\":\"49999.00000000\",\"h\":\"49999.00000000\",\"l\":\"49999.00000000\",\"v\":\"0.00000000\",\"q\":\"0.00000000\",\"O\":1555600601881,\"C\":1555687001881,\"F\":\"8274485-0\",\"L\":\"8274485-0\",\"n\":0}}\n\n----- Customized handler -----\n{\"stream\":\"ticker\",\"data\":{\"e\":\"24hrTicker\",\"E\":1555687043,\"s\":\"100K-9BC_BNB\",\"p\":\"0.00000000\",\"P\":\"0.00000000\",\"w\":\"49999.00000000\",\"x\":\"49999.00000000\",\"c\":\"49999.00000000\",\"Q\":\"0.00009820\",\"b\":\"0.00000000\",\"B\":\"0.00000000\",\"a\":\"4700.00000000\",\"A\":\"0.13197840\",\"o\":\"49999.00000000\",\"h\":\"49999.00000000\",\"l\":\"49999.00000000\",\"v\":\"0.00000000\",\"q\":\"0.00000000\",\"O\":1555600601881,\"C\":1555687001881,\"F\":\"8274485-0\",\"L\":\"8274485-0\",\"n\":0}}\n```\n[++Find more Web Socket Doc by clicking this link++](https://github.com/wally-yu/binance-dex/blob/master/README_WebSockets.md)\n\n\n---\n#### - Node RPC Sample Usage\n\n```\nfrom binance_dex.node_rpc import BinanceChainNodeRPC\n\n# Create Instance\n\n# OPTION 1: using existing RPC node\nnode_rpc_instance = BinanceChainNodeRPC(is_test_net=True,\n node_rpc_url=None)\n\n# OPTION 2: using your own node\n# node_rpc_instance = BinanceChainNodeRPC(node_rpc_url='https://seed-pre-s3.binance.org')\n\n# Get number of unconfirmed transactions\nprint(node_rpc_instance.num_unconfirmed_txs()) \n```\nSample return\n\n```\nUsing Existing RPC server, trying to find a healthy node server...\n\nRequest URL: https://seed-pre-s3.binance.org:443/health ... ...\n\nSuccessfully found healthy node RPC server: https://seed-pre-s3.binance.org:443\n\nRequest URL: https://seed-pre-s3.binance.org:443/num_unconfirmed_txs ... ...\n{'status': True, 'result': {'jsonrpc': '2.0', 'id': '', 'result': {'n_txs': '0', 'txs': None}}}\n```\n[++Find more Node RPC Doc by clicking this link++](https://github.com/wally-yu/binance-dex/blob/master/README_NodeRPC.md)\n\n\n\n## SDK Overview\nAs you might noticed from above code sample, this SDK is composed with 4 parts:\n- API\n- WebSockets\n- Node RPC\n- Crypto\n\n#### Description\n- **API:** HTTP API provides access to a Binance Chain node deployment and market data services [DETAILED API DOC](https://github.com/wally-yu/binance-dex/blob/master/README_API.md)\n\n- **Web Sockets:** The DEX exposes several data streams over standard WebSocket connections, which can be consumed by modern web browsers and server-side WebSocket libraries [DETAILED SOCKET DOC](https://github.com/wally-yu/binance-dex/blob/master/README_WebSockets.md)\n\n- **Node RPC:** May be used to interact with a node directly over HTTP or websockets. Using RPC, you may perform low-level operations like executing ABCI queries, viewing network/consensus state or broadcasting a transaction [DETAILED NODE DOC](https://github.com/wally-yu/binance-dex/blob/master/README_NodeRPC.md)\n\n- **Crypto:** Crypto related functions (such as key managment) [DETAILED CRYPTO DOC](https://github.com/wally-yu/binance-dex/blob/master/README_Crypto.md)\n\n#### Availability:\n\n\n
| \n | \n | API | \nWebSockets | \nNode RPC | \nCrypto | \n
|---|---|---|---|---|---|
| Key | \ngenerate mnemonic | \n\n | \n | \n | √ | \n
| generate key | \n\n | \n | \n | √ | \n|
| generate keys | \n\n | \n | \n | √ | \n|
| Chain | \nget block height | \n√ | \n√ | \n\n | √ | \n
| get block info | \n\n | \n | √ | \n\n | |
| get consensue info | \n\n | \n | √ | \n\n | |
| get network info | \n\n | \n | √ | \n\n | |
| get unconfirmed tx | \n\n | \n | √ | \n\n | |
| get Tendermint status | \n\n | \n | √ | \n\n | |
| Node | \nget block time | \n√ | \n\n | \n | \n |
| get node info | \n√ | \n\n | \n | \n | |
| get validators | \n√ | \n\n | √ | \n\n | |
| get peers | \n√ | \n\n | \n | \n | |
| get end points | \n\n | \n | √ | \n\n | |
| get abci info | \n\n | \n | √ | \n\n | |
| Market | \nget listing tokens | \n√ | \n\n | \n | \n |
| get trading pairs | \n√ | \n√ | \n\n | \n | |
| get depth | \n√ | \n√ | \n\n | \n | |
| get klines | \n√ | \n√ | \n\n | \n | |
| get updated ticker statistics | \n√ | \n√ | \n\n | \n | |
| Account | \nget account balance | \n√ | \n√ | \n\n | \n |
| get account sequence | \n√ | \n\n | \n | \n | |
| get account orders | \n\n | √ | \n\n | \n | |
| Transaction | \nget transaction info | \n√ | \n\n | √ | \n\n |
| broadcast transaction | \n√ | \n\n | √ | \n\n | |
| Others | \nview chain fees | \n√ | \n\n | \n | \n |