<p><code>bitcoind</code> doesn't give you a way to query this, but by looking at the files it writes to disk, we can build our own tools that let us look at this. One such tool is Abe, and this is how you use it:</p>

<h1>Installation (Ubuntu)</h1>

<p>I'm assuming you have the standard bitcoin client running already.</p>

<p>Download <a href="https://github.com/jtobey/bitcoin-abe" rel="nofollow">Abe</a>. Unpack it, and run <code>python setup.py install</code></p>

<p>Go into <code>abe.conf</code> and add these lines:</p>

<pre><code># SQLite3 example:
dbtype = sqlite3
connect-args = abe.sqlite
# Specify port and/or host to serve HTTP instead of FastCGI:
port 2750
host localhost
</code></pre>

<h3>A note about firstbits</h3>

<p>If you want to do firstbits lookups, you need to add one more line to the config.</p>

<pre><code>use-firstbits
</code></pre>

<p>Note that you need to do this <em>before</em> you run abe, or else you'll need to run Abe.reconfigure too.</p>

<h3>Back to the normal installation</h3>

<p>Run <code>python -m Abe.abe --config /path/to/abe.conf</code></p>

<p>You should see the screen get spammed with </p>

<pre><code>block_tx 38944 39254
commit
</code></pre>

<p>At time of writing, this will need to count up to <a href="http://blockexplorer.com/q/getblockcount" rel="nofollow">220,000</a>. This took me about 8 hours. After the first startup, it will load in about a second.</p>

<p>Try opening <code>http://localhost:2750/</code>. If it shows no data, then there was an error. The output that the abe command produced immediately before saying that it was listening should give you some sort of insight.</p>

<p>Now your application can issue http requests to find out about the blockchain! There is a link to some documentation (<code>http://localhost:2750/q</code>), but you'll mostly be interested in </p>

<ul>
<li><code>getreceivedbyaddress</code> (<code>http://localhost:2750/chain/Bitcoin/q/getreceivedbyaddress/ADDRESS</code>)</li>
<li><code>getsentbyaddress</code> (<code>http://localhost:2750/chain/Bitcoin/q/getsentbyaddress/ADDRESS</code>)</li>
<li><code>fb</code> (<code>http://localhost:2750/q/fb/ADDRESS</code>)</li>
</ul>

CC BY-SA 3.0
2016-06-08T10:58:55.853Z
I tried this but I got the error message `ImportError: No module named NCTestnet`
smatthewenglish
CC BY-SA 3.0
2012-11-27T09:23:33.970Z
2015-11-17T17:52:21.870Z
2015-11-17T17:52:21.870Z
Nick ODell
<p>I am actually working on doing this myself for a project, like the above poster said you can use the bitcoind API.</p>

<p>To get the information on addresses you don't own the commands "getrecievedbyaddress" and so on wont work.</p>

<p>You will need to work your way through the blockchain which can take a long time and i would not recommend doing it manually.</p>

<p>Here is the order of commands you would follow in order to do follow the blockchain.</p>

<ol>
<li>getblockcount - this will give you the total number of blocks in the network</li>
<li><p>Now starts the endless loop of going from block to block with the following command - getblockhash {index} index the is block height. For example when you do block count you might see something like 200890. So the index of the last block is 200890 so you would input <code>getblockhash 200890</code> which will return the hash number of a block.</p></li>
<li><p><code>getblock {hash}</code> This command now gives you all the transactions within the block. </p></li>
<li><p>Now your going to use each transaction ID in the block with the following command <code>getrawtransaction {txid}</code> This is going to give you a list of the inputs and outputs of each transaction. Here you will see the addresses which received and sent within that transaction and the amount involved.</p></li>
</ol>

<p>Now you'll basically loop this until you've built up a database of the entire blockchain, their is no easy way to do it unfortunately. I am just starting out on all these steps so i may have missed something, but the general idea is thier.</p>

<p>Hopefully you find that block of text useful in some way =)</p>

CC BY-SA 3.0
2012-11-27T19:03:16.760Z
2012-11-27T19:03:16.760Z
Andrew Font
<p>To see all transactions recently made (by anyone on the network), you can use the <code>getrawmemorypool</code> RPC call, it will give you a list of all txids in the memory pool (not yet in a block). Those can be passed to <code>getrawtransaction</code> to retrieve the actual transaction. <code>getblock</code> can be used to see the transactions in recent blocks.</p>

<p>Querying the unspent outputs by address (required to calculate the "balance") requires an index from addresses to txids. Bitcoind does not maintain such an index, as it is not required for normal operation, but it may be added as an optional feature somewhere in the future.</p>

CC BY-SA 3.0
2012-11-27T21:24:52.897Z
2012-11-27T21:24:52.897Z
Pieter Wuille
<p>You can use the API to access each block, and then Raw Transactions to access each transaction within each block.  It isn't trivial but it can be done.</p>

<ul>
<li><a href="http://en.bitcoin.it/wiki/Raw_Transactions" rel="nofollow">http://en.bitcoin.it/wiki/Raw_Transactions</a></li>
</ul>

CC BY-SA 3.0
2012-11-27T19:00:32.037Z
Seems like this might take a while if you wanted to figure out the balance of an account. It's probably the right move if you want to find out about recent transactions, though. Good information!
Nick ODell
CC BY-SA 3.0
2012-11-27T11:01:26.633Z
2012-11-27T11:01:26.633Z
Stephen Gornick
<p>Suppose I want to </p>

<ul>
<li>get the balance of an address I don't own, or</li>
<li>see all the transactions recently made</li>
</ul>

<p>Bitcoin Block Explorer has this information, but I don't want to use it</p>

<ul>
<li>because of security (they might lie)</li>
<li>because of privacy (they might log queries)</li>
<li>because it introduces an additional point of failure</li>
<li>because it's not terribly quick, being a free service and all</li>
</ul>

<p>How can I get this information from my <code>bitcoind</code>?</p>

<blockexplorer>
How do I access information on blockexplorer.com or blockchain.info without issuing requests to those websites?
Nick ODell
# How do I access information on blockexplorer.com or blockchain.info without issuing requests to those websites?

(Asked by: username_0 on 2012-11-27)

Suppose I want to

* get the balance of an address I don't own, or
* see all the transactions recently made

Bitcoin Block Explorer has this information, but I don't want to use it

* because of security (they might lie)
* because of privacy (they might log queries)
* because it introduces an additional point of failure
* because it's not terribly quick, being a free service and all

How can I get this information from my `bitcoind`?

**Tags:** blockexplorer


---

## 4 answers

### Answer by username_0 on 2012-11-27. Score: 8

`bitcoind` doesn't give you a way to query this, but by looking at the files it writes to disk, we can build our own tools that let us look at this. One such tool is Abe, and this is how you use it:

# Installation (Ubuntu)

I'm assuming you have the standard bitcoin client running already.

Download [Abe](https://github.com/jtobey/bitcoin-abe). Unpack it, and run `python setup.py install`

Go into `abe.conf` and add these lines:

```
# SQLite3 example:
dbtype = sqlite3
connect-args = abe.sqlite
# Specify port and/or host to serve HTTP instead of FastCGI:
port 2750
host localhost

```

### A note about firstbits

If you want to do firstbits lookups, you need to add one more line to the config.

```
use-firstbits

```

Note that you need to do this *before* you run abe, or else you'll need to run Abe.reconfigure too.

### Back to the normal installation

Run `python -m Abe.abe --config /path/to/abe.conf`

You should see the screen get spammed with

```
block_tx 38944 39254
commit

```

At time of writing, this will need to count up to [220,000](http://blockexplorer.com/q/getblockcount). This took me about 8 hours. After the first startup, it will load in about a second.

Try opening `http://localhost:2750/`. If it shows no data, then there was an error. The output that the abe command produced immediately before saying that it was listening should give you some sort of insight.

Now your application can issue http requests to find out about the blockchain! There is a link to some documentation (`http://localhost:2750/q`), but you'll mostly be interested in

* `getreceivedbyaddress` (`http://localhost:2750/chain/Bitcoin/q/getreceivedbyaddress/ADDRESS`)
* `getsentbyaddress` (`http://localhost:2750/chain/Bitcoin/q/getsentbyaddress/ADDRESS`)
* `fb` (`http://localhost:2750/q/fb/ADDRESS`)

> **Comments:**
> **username_1**: I tried this but I got the error message `ImportError: No module named NCTestnet`  

---

### Answer by username_2 on 2012-11-27. Score: 6

I am actually working on doing this myself for a project, like the above poster said you can use the bitcoind API.

To get the information on addresses you don't own the commands "getrecievedbyaddress" and so on wont work.

You will need to work your way through the blockchain which can take a long time and i would not recommend doing it manually.

Here is the order of commands you would follow in order to do follow the blockchain.

1. getblockcount - this will give you the total number of blocks in the network
2. Now starts the endless loop of going from block to block with the following command - getblockhash {index} index the is block height. For example when you do block count you might see something like 200890. So the index of the last block is 200890 so you would input `getblockhash 200890` which will return the hash number of a block.
3. `getblock {hash}` This command now gives you all the transactions within the block.
4. Now your going to use each transaction ID in the block with the following command `getrawtransaction {txid}` This is going to give you a list of the inputs and outputs of each transaction. Here you will see the addresses which received and sent within that transaction and the amount involved.

Now you'll basically loop this until you've built up a database of the entire blockchain, their is no easy way to do it unfortunately. I am just starting out on all these steps so i may have missed something, but the general idea is thier.

Hopefully you find that block of text useful in some way =)


---

### Answer by username_3 on 2012-11-27. Score: 2

To see all transactions recently made (by anyone on the network), you can use the `getrawmemorypool` RPC call, it will give you a list of all txids in the memory pool (not yet in a block). Those can be passed to `getrawtransaction` to retrieve the actual transaction. `getblock` can be used to see the transactions in recent blocks.

Querying the unspent outputs by address (required to calculate the "balance") requires an index from addresses to txids. Bitcoind does not maintain such an index, as it is not required for normal operation, but it may be added as an optional feature somewhere in the future.


---

### Answer by username_4 on 2012-11-27. Score: 1

You can use the API to access each block, and then Raw Transactions to access each transaction within each block. It isn't trivial but it can be done.

* <http://en.bitcoin.it/wiki/Raw_Transactions>

> **Comments:**
> **username_0**: Seems like this might take a while if you wanted to figure out the balance of an account. It's probably the right move if you want to find out about recent transactions, though. Good information!  

---

