<p>One could extract the Blockchain and import it to your own database for analysis.  For example, see project: <a href="https://github.com/in3rsha/bitcoin-to-neo4j" rel="nofollow noreferrer">bitcoin-to-neo4j</a>.</p>

CC BY-SA 3.0
2017-12-24T17:47:47.433Z
2017-12-24T17:47:47.433Z
AWhitford
<p>My recommendation would be to use <a href="https://github.com/citp/BlockSci" rel="nofollow noreferrer">BlockSci</a>, an in-memory blockchain database with a Python interface that allows to do this kind of queries in a very efficient way.</p>

<p>For instance, you can build this plot with the average transaction size:
<a href="https://i.sstatic.net/uKzqS.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/uKzqS.png" alt="enter image description here"></a> </p>

<p>with just a few lines of code:</p>

<pre><code>import blocksci
import numpy as np
chain = blocksci.Blockchain(DATA_DIR)
tx_size = [(block.height, np.mean(block.txes.size_bytes)) for block in chain]
df_tx_size = pd.DataFrame(tx_size, columns=["Height", "Avg. tx size"])
df = chain.heights_to_dates(df_tx_size)
del df["Height"]
ax = df.resample("M").mean().plot()
</code></pre>

CC BY-SA 3.0
2018-03-02T15:59:57.877Z
2018-03-03T22:01:38.210Z
2018-03-03T22:01:38.210Z
cpsola
<p>Your best bet without downloading the entire blockchain is use stats from here: <a href="https://blockchain.info/stats" rel="nofollow noreferrer">https://blockchain.info/stats</a></p>

<p>But if you want to query the bitcoin blockchain locally, you'll need to download the 120+GB blockchain and then write up a custom script to consume the data manually to do what you need. Time intensive if you are willing to invest in it. Otherwise best to use publicly available stats and data and work off of that. </p>

CC BY-SA 3.0
2017-10-25T15:39:04.983Z
2017-10-25T15:39:04.983Z
Patoshi パトシ
<p>I want to find out how many addresses have had x transactions over time. </p>

<p>I want to find out the average bitcoin transaction size for  over time...I want to do a bunch of different queries like that on a regular basis.</p>

<p>Big picture: I want to do fundamental research on block chain activity and publish it. I have worked a decent bit with databases in the past. How can I learn to interact proficiently with the bitcoin blockchain?</p>

CC BY-SA 3.0
2017-10-24T18:34:45.693Z
Possible duplicate of https://bitcoin.stackexchange.com/questions/19371/how-can-i-view-the-blockchain-locally-on-my-machine
Denis Leonov
<blockchain><query>
How to learn to query the block chain?
Gabe Harris
# How to learn to query the block chain?

(Asked by: username_0 on 2017-10-24)

I want to find out how many addresses have had x transactions over time.

I want to find out the average bitcoin transaction size for over time...I want to do a bunch of different queries like that on a regular basis.

Big picture: I want to do fundamental research on block chain activity and publish it. I have worked a decent bit with databases in the past. How can I learn to interact proficiently with the bitcoin blockchain?

**Tags:** blockchain, query

> **Comments:**
> **username_1**: Possible duplicate of https://bitcoin.stackexchange.com/questions/19371/how-can-i-view-the-blockchain-locally-on-my-machine  

---

## 3 answers

### Answer by username_2 on 2017-12-24. Score: 2

One could extract the Blockchain and import it to your own database for analysis. For example, see project: [bitcoin-to-neo4j](https://github.com/in3rsha/bitcoin-to-neo4j).


---

### Answer by username_3 on 2018-03-02. Score: 1

My recommendation would be to use [BlockSci](https://github.com/citp/BlockSci), an in-memory blockchain database with a Python interface that allows to do this kind of queries in a very efficient way.

For instance, you can build this plot with the average transaction size:
[![enter image description here](https://i.sstatic.net/uKzqS.png)](https://i.sstatic.net/uKzqS.png)

with just a few lines of code:

```
import blocksci
import numpy as np
chain = blocksci.Blockchain(DATA_DIR)
tx_size = [(block.height, np.mean(block.txes.size_bytes)) for block in chain]
df_tx_size = pd.DataFrame(tx_size, columns=["Height", "Avg. tx size"])
df = chain.heights_to_dates(df_tx_size)
del df["Height"]
ax = df.resample("M").mean().plot()

```


---

### Answer by username_4 on 2017-10-25. Score: 0

Your best bet without downloading the entire blockchain is use stats from here: <https://blockchain.info/stats>

But if you want to query the bitcoin blockchain locally, you'll need to download the 120+GB blockchain and then write up a custom script to consume the data manually to do what you need. Time intensive if you are willing to invest in it. Otherwise best to use publicly available stats and data and work off of that.


---

