|
| 1 | +#Blockchain API library (Python, v1) |
| 2 | + |
| 3 | +An official Python module for interacting with the Blockchain.info API. |
| 4 | + |
| 5 | +##Getting started |
| 6 | + |
| 7 | +The module consists of the following sub-modules: |
| 8 | + |
| 9 | +* `blockchaindata` ([api/blockchain_api][api1]) |
| 10 | +* `createwallet` ([api/create_wallet][api2]) |
| 11 | +* `exchangerates` ([api/exchange\_rates\_api][api3]) |
| 12 | +* `receive` ([api/api_receive][api4]) |
| 13 | +* `statistics` ([api/charts_api][api5]) |
| 14 | +* `wallet` ([api/blockchain\_wallet\_api][api6]) |
| 15 | + |
| 16 | +The main module is called `blockchain` |
| 17 | + |
| 18 | +##Usage |
| 19 | + |
| 20 | + |
| 21 | +###`blockchaindata` module |
| 22 | +All functions support an optional parameter called `api_code` |
| 23 | + |
| 24 | +Get a single block based on a block index or hash: |
| 25 | + |
| 26 | +``` |
| 27 | +from blockchain import blockchaindata |
| 28 | +
|
| 29 | +block = blockchaindata.get_block('000000000000000016f9a2c3e0f4c1245ff24856a79c34806969f5084f410680') |
| 30 | +``` |
| 31 | + |
| 32 | +###Response object field definitions |
| 33 | + |
| 34 | +####`Block` |
| 35 | + |
| 36 | +``` |
| 37 | +hash : str |
| 38 | +version : int |
| 39 | +previous_block (str |
| 40 | +merkle_root :str |
| 41 | +time : int |
| 42 | +bits : int |
| 43 | +fee : int |
| 44 | +nonce int |
| 45 | +t_tx : int |
| 46 | +size : int |
| 47 | +block_index : int |
| 48 | +main_chain : bool |
| 49 | +height : int |
| 50 | +received_time : int |
| 51 | +relayed_by : string |
| 52 | +transactions : array of Transaction objects |
| 53 | +``` |
| 54 | + |
| 55 | +####`Transaction` |
| 56 | + |
| 57 | +``` |
| 58 | +double_spend : bool |
| 59 | +block_height : int |
| 60 | +time : int |
| 61 | +relayed_by : str |
| 62 | +hash : str |
| 63 | +tx_index : int |
| 64 | +version : int |
| 65 | +size : int |
| 66 | +inputs : array of Input objects |
| 67 | +outputs: array of Output objects |
| 68 | +``` |
| 69 | + |
| 70 | +####`Input` |
| 71 | + |
| 72 | +``` |
| 73 | +n : int |
| 74 | +value : int |
| 75 | +address : str |
| 76 | +tx_index : int |
| 77 | +type : int |
| 78 | +script : str |
| 79 | +script_sig : str |
| 80 | +sequence : int |
| 81 | +``` |
| 82 | + |
| 83 | +Note: if coinbase transaction, then only `script` and `script_siq` will be populated. |
| 84 | + |
| 85 | +####`Output` |
| 86 | + |
| 87 | +``` |
| 88 | +n : int |
| 89 | +value : int |
| 90 | +address : str |
| 91 | +tx_index : int |
| 92 | +type : int |
| 93 | +script : str |
| 94 | +spent : bool |
| 95 | +``` |
| 96 | + |
| 97 | +####`Address` |
| 98 | + |
| 99 | +``` |
| 100 | +hash160 : str |
| 101 | +address : str |
| 102 | +n_tx : int |
| 103 | +total_received : int |
| 104 | +total_sent : int |
| 105 | +final_balance : int |
| 106 | +transactions : array of Transaction objects |
| 107 | +
|
| 108 | +``` |
| 109 | + |
| 110 | +####`UnspentOutput` |
| 111 | + |
| 112 | +``` |
| 113 | +tx_hash : str |
| 114 | +tx_index : int |
| 115 | +tx_output_n : int |
| 116 | +script : str |
| 117 | +value : int |
| 118 | +value_hex : str |
| 119 | +confirmations : int |
| 120 | +``` |
| 121 | + |
| 122 | +####`LatestBlock` |
| 123 | + |
| 124 | +``` |
| 125 | +hash : str |
| 126 | +time : int |
| 127 | +block_index : int |
| 128 | +height : int |
| 129 | +tx_indexes : array of TX indexes (integers) |
| 130 | +``` |
| 131 | + |
| 132 | +####`SimpleBlock` |
| 133 | + |
| 134 | +``` |
| 135 | +height : int |
| 136 | +hash : str |
| 137 | +time : int |
| 138 | +main_chain : bool |
| 139 | +``` |
| 140 | + |
| 141 | +####`InventoryData` |
| 142 | + |
| 143 | +``` |
| 144 | +hash : str |
| 145 | +type : str |
| 146 | +initial_time : int |
| 147 | +initial_ip : str |
| 148 | +nconnected : int |
| 149 | +relayed_count : int |
| 150 | +relayed_percent : int |
| 151 | +probable_owners : array of ProbableOwner objects (ip : str, confidence : int) |
| 152 | +mining_nodes : array of MiningNode objects (link : str, name : str) |
| 153 | +``` |
| 154 | + |
| 155 | + |
| 156 | +[api1]: https://blockchain.info/api/blockchain_api |
| 157 | +[api2]: https://blockchain.info/api/create_wallet |
| 158 | +[api3]: https://blockchain.info/api/exchange_rates_api |
| 159 | +[api4]: https://blockchain.info/api/api_receive |
| 160 | +[api5]: https://blockchain.info/api/charts_api |
| 161 | +[api6]: https://blockchain.info/api/blockchain_wallet_api |
0 commit comments