Skip to content

Commit 3f04530

Browse files
author
Vedran
committed
README updates
1 parent 7a63c05 commit 3f04530

File tree

3 files changed

+166
-9
lines changed

3 files changed

+166
-9
lines changed

README.md

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
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

blockchain/blockchaindata.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,6 @@ def __init__(self, t):
215215
self.double_spend = t.get('double_spend', False)
216216
self.block_height = t.get('block_height')
217217
self.time = t['time']
218-
self.vout_sz = t['vout_sz']
219-
self.vin_sz = t['vin_sz']
220218
self.relayed_by = t['relayed_by']
221219
self.hash = t['hash']
222220
self.tx_index = t['tx_index']
@@ -250,18 +248,18 @@ class InventoryData:
250248
def __init__(self, i):
251249
self.hash = i['hash']
252250
self.type = i['type']
253-
self.initial_time = i['initial_time']
251+
self.initial_time = int(i['initial_time'])
254252
self.initial_ip = i['initial_ip']
255-
self.nconnected = i['nconnected']
256-
self.relayed_count = i['relayed_count']
257-
self.relayed_percent = i['relayed_percent']
253+
self.nconnected = int(i['nconnected'])
254+
self.relayed_count = int(i['relayed_count'])
255+
self.relayed_percent = int(i['relayed_percent'])
258256
self.probable_owners =[]
259257
self.mining_nodes = []
260258

261259
for o in i['probable_owners']:
262260
owner = ProbableOwner()
263261
owner.ip = o['ip']
264-
owner.confidence = o['confidence']
262+
owner.confidence = int(o['confidence'])
265263
probable_owners.append(owner)
266264

267265
for m in i['mining_nodes']:

blockchain/util.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
import urllib2
33

44
from .exceptions import *
5-
from validation import validate
6-
from urlparse import urlparse
75

86
BASE_URL = "https://blockchain.info/"
97

0 commit comments

Comments
 (0)