Is there an easy way to access all transactions recorded in a bitcoin block with certain block height using Python?

元气小坏坏 提交于 2021-01-28 02:24:00

问题


I would like to retrive all transactions within a block with a certain block height, without running a full node or downloading a few GB of data.

Not sticking to Python, tried to use the Block Height section of this. Following the example given there,

https://blockchain.info/block-height/$100?format=json

returns:

Invalid Numerical Value

Is there an easy, Pythonic way to do this?


回答1:


You have to use without $ which was only information that $block_height is not part of url but variable which you have to replace,

https://blockchain.info/block-height/100?format=json

import requests

r = requests.get('https://blockchain.info/block-height/100?format=json')
data = r.json()

#print(r.text)
#print(data)
print(data['blocks'][0]['hash'])


来源:https://stackoverflow.com/questions/61858764/is-there-an-easy-way-to-access-all-transactions-recorded-in-a-bitcoin-block-with

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!