2

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.

3

Your best bet is to run a bitcoind node locally and then connect to it using zmq (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.

  • Thanks. Also very interesting to hear it uses ZeroMQ as I wanted to learn that anyway. – Kelly Sep 21 '16 at 0:03
0

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

    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 for examples how to query the bitcoind in bulk.

    • 1
      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 Sep 21 '16 at 9:16
    • If you want to "read the whole thing", then -txindex the s*** out of it. – Cole Albon Sep 21 '16 at 16:30
    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?

    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).

      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.