<p>Your best bet is to run a <a href="https://bitcoin.org/en/bitcoin-core/" rel="nofollow noreferrer">bitcoind</a> node locally and then connect to it using <a href="http://zeromq.org/" rel="nofollow noreferrer">zmq</a> (ZeroMQ).</p>

<p>Pulling it from anywhere else means you're trusting someone else and the data can easily be corrupted. Also blockchain.info has a horrible track record of being wrong and being down very often.</p>

CC BY-SA 3.0
2016-09-21T00:03:00.543Z
Thanks. Also very interesting to hear it uses ZeroMQ as I wanted to learn that anyway.
Kelly
CC BY-SA 3.0
2016-09-20T14:10:01.207Z
2016-11-03T10:01:13.997Z
2016-11-03T10:01:13.997Z
Jannes
<p>I was interested in the same thing. My solution was to connect to a specific node (I chose the one running on my server), and start reading the messages it sends me over TCP/IP.</p>

<p>Here's a link to the initial script I wrote (it's PHP). It performs the handshake with the node, and starts receiving the latest blocks and transactions from that node:</p>

<p><a href="https://bitcoin.stackexchange.com/questions/48363/is-it-possible-to-read-every-transaction-my-node-relays/48399#48399">Is it possible to read every transaction my node relays?</a></p>

<p>As far as reading the whole existing blockchain, you can either send messages to that node asking for every block in their blockchain, or run a bitcion node yourself and read the blk*.dat files from your computer (which would have been received by your node asking for each block in the way I just mentioned).</p>

CC BY-SA 3.0
2016-09-23T13:44:19.917Z
2016-09-23T13:44:19.917Z
2017-04-13T12:47:34.187Z
inersha
<p>The whole chain can be downloaded with bitcoind assuming you launch bitcoind with --txindex flag.  Expect a few days to sync up on a fast machine then it just stays current on its own.</p>

<p>Once current, a good way to learn the commands is to use bitcoin-cli there are a ton of messy shell scripts <a href="https://github.com/colealbon/blockchain-analytics" rel="nofollow">here</a> for examples how to query the bitcoind in bulk.</p>

CC BY-SA 3.0
2016-09-21T09:16:06.747Z
txindex flag doesn't affect what is downloaded or not: bitcoind *always* downloads the whole chain. Also, txindex seems irrelevant to the original question here, although it may be useful.
Jannes
CC BY-SA 3.0
2016-09-21T16:30:35.770Z
If you want to "read the whole thing", then -txindex the s*** out of it.
Cole Albon
CC BY-SA 3.0
2016-09-20T19:20:25.137Z
2016-09-20T19:20:25.137Z
Cole Albon
<p>Your best bet to get blockchain data in is via this: <a href="https://blockchain.info/api" rel="nofollow">https://blockchain.info/api</a> </p>

CC BY-SA 3.0
2016-09-20T04:48:39.540Z
2016-09-20T04:48:39.540Z
Patoshi パトシ
<p>I would like to connect to the blockchain to read the whole thing, then listen to it "live" as it streams. </p>

<p>I'm new to this and can't seem to find out how to connect to receive data. (is there a central server, is it peer to peer...)</p>

<p>Is it a push or pull type of format? ie: Do I need to setup and endpoint and register to get the stream, or do I need to poll something?</p>

<p>Again new to this, any help would be appreciated.</p>

CC BY-SA 3.0
2016-09-20T07:11:05.013Z
It uses P2P, I recommend that you read this. https://bitcoin.org/en/how-it-works
Web Weave
<blockchain><zeromq>
Where to connect to get streaming blockchain data?
Kelly
# Where to connect to get streaming blockchain data?

(Asked by: username_0 on 2016-09-20)

I would like to connect to the blockchain to read the whole thing, then listen to it "live" as it streams.

I'm new to this and can't seem to find out how to connect to receive data. (is there a central server, is it peer to peer...)

Is it a push or pull type of format? ie: Do I need to setup and endpoint and register to get the stream, or do I need to poll something?

Again new to this, any help would be appreciated.

**Tags:** blockchain, zeromq

> **Comments:**
> **username_1**: It uses P2P, I recommend that you read this. https://bitcoin.org/en/how-it-works  

---

## 4 answers

### Answer by username_2 on 2016-09-20. Score: 3 | Accepted answer

Your best bet is to run a [bitcoind](https://bitcoin.org/en/bitcoin-core/) node locally and then connect to it using [zmq](http://zeromq.org/) (ZeroMQ).

Pulling it from anywhere else means you're trusting someone else and the data can easily be corrupted. Also blockchain.info has a horrible track record of being wrong and being down very often.

> **Comments:**
> **username_0**: Thanks. Also very interesting to hear it uses ZeroMQ as I wanted to learn that anyway.  

---

### Answer by username_3 on 2016-09-23. Score: 0

I was interested in the same thing. My solution was to connect to a specific node (I chose the one running on my server), and start reading the messages it sends me over TCP/IP.

Here's a link to the initial script I wrote (it's PHP). It performs the handshake with the node, and starts receiving the latest blocks and transactions from that node:

[Is it possible to read every transaction my node relays?](https://bitcoin.stackexchange.com/questions/48363/is-it-possible-to-read-every-transaction-my-node-relays/48399#48399)

As far as reading the whole existing blockchain, you can either send messages to that node asking for every block in their blockchain, or run a bitcion node yourself and read the blk\*.dat files from your computer (which would have been received by your node asking for each block in the way I just mentioned).


---

### Answer by username_4 on 2016-09-20. Score: 0

The whole chain can be downloaded with bitcoind assuming you launch bitcoind with --txindex flag. Expect a few days to sync up on a fast machine then it just stays current on its own.

Once current, a good way to learn the commands is to use bitcoin-cli there are a ton of messy shell scripts [here](https://github.com/username_4/blockchain-analytics) for examples how to query the bitcoind in bulk.

> **Comments:**
> **username_2**: txindex flag doesn't affect what is downloaded or not: bitcoind *always* downloads the whole chain. Also, txindex seems irrelevant to the original question here, although it may be useful.  
> **username_4**: If you want to "read the whole thing", then -txindex the s*** out of it.  

---

### Answer by username_5 on 2016-09-20. Score: 0

Your best bet to get blockchain data in is via this: <https://blockchain.info/api>


---

