I need to read all Bitcoin transactions from the first one until now and extract all Bitcoin addresses for further analyses

Any idea how to do it in Python?


I once used blockchain.info APIs in python for similar purpose, you can traverse with block height from 0 to latest with a python script. And can write input and output addresses to a csv file. You can use 'set' to make sure there is no duplicates.

You will get response as json object. But it might be quite time consuming to fetch and read all the blocks and transactions.

  • Really slow, I have bitcoin-core up and running and I don't need blockchain.info APIs (network overhead) but still, bitcoin-core is slow too I need to find a way to read blocks with levelDB one by one but I don't know how – John Kotkin Sep 10 '17 at 14:20
  • I don't know much in the context then, can't help.. – Piyush Chittara Sep 10 '17 at 16:31

I do not know the python language but the algorihtm for blockchain parsing is very simple. Take some pseudocode:

for ( i = 0; ; i++ )
  openBlkFile ( i );
  while ( readBlock ( block ) )
    parseBlockForTransactions ( block );

Of course, you need to have synchronized node.


To expand on Amaclin's answer you can look into JSON-RPC python wrappers such as python-bitcoinrpc which will allow you to make calls to your nodes database. With a fully synced node and txindex=1 you can begin iterating through each block with for loops with getblockhash getblock getrawtransaction and decoderawtransaction. Yes, this will take a long time.


I wrote the Python script that can parse bitcoin raw dumps. There is no need of any modules or APIs, just Puthon 2.7 and blk00*.dat files. I hope it can help.

Blockchain parser

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.