<p>Get the block count: </p>

<pre><code>http://blockchain.info/q/getblockcount
</code></pre>

<p>Subtract 3 from that number.</p>

<p>Get the transactions from the address you're looking for: </p>

<pre><code>http://blockchain.info/address/$bitcoin_address?format=json&amp;limit=50&amp;offset=0
</code></pre>

<p>This returns 50 transactions by default, change the 'limit' value to wherever you might need it to be. Setting 'offset' to 5 will allow you to skip the first 5 transactions. Make sure you don't set offset to something greater than the total number of transactions on a particular address, it won't ever return anything. </p>

<p>Then set up your code to ignore any transaction that's newer than 3 blocks ago.</p>

CC BY-SA 3.0
2013-05-01T05:12:38.803Z
2014-10-28T17:03:25.237Z
2014-10-28T17:03:25.237Z
Morichalion
<p>You can do this in two API calls, plus some filtering:</p>

<ol>
<li>Get the current block height from <code>http://blockchain.info/latestblock</code></li>
<li>Get the list of transactions for the address from <code>http://blockchain.info/address/$hash_160?format=json</code> </li>
<li>Filter transactions from #2 where the height is less than current block height minus 3.</li>
</ol>

<p>Rough Ruby code:</p>

<pre><code>require 'open-uri'
require 'json'
require 'pp'

desired_address = '1dice7W2AicHosf5EL3GFDUVga7TgtPFn' #high traffic address good for example code!
get_transactions_with_minimum_of_n_confirmations = 3

latestblock = JSON.parse open('http://blockchain.info/latestblock').read
address = JSON.parse open("http://blockchain.info/address/#{desired_address}?format=json").read

current_block_height = latestblock["height"]
pp address["txs"].select {|tx| tx["block_height"] &lt; (current_block_height - get_transactions_with_minimum_of_n_confirmations) }
</code></pre>

<p>Keep in mind that you're going to retrieve a list of ALL transactions involving that address. It'd be nice of Blockchain.info let you specify a minimum number of confirmations to limit transactions to on the address call.</p>

CC BY-SA 3.0
2013-04-20T02:43:17.023Z
2013-04-20T02:43:17.023Z
Colin Dean
<p>I need to query blockchain.info with an address and determine how much is there, ignoring transactions that don't have 3 confirmations.</p>

<p>Can anyone give me a hint how to do this?</p>

CC BY-SA 3.0
2013-04-19T13:24:03.670Z
_What?_ could you rephrase?
o0'.
CC BY-SA 3.0
2013-04-19T17:05:57.593Z
This sounds a bit like an [XY problem](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). I'm guessing that you want to take payments, right?
Nick ODell
CC BY-SA 3.0
2013-04-19T17:45:48.597Z
Have you read through http://blockchain.info/api?
ripper234
<blockchain.info>
How to query blockchain.info?
Claudiu
# How to query blockchain.info?

(Asked by: username_0 on 2013-04-19)

I need to query blockchain.info with an address and determine how much is there, ignoring transactions that don't have 3 confirmations.

Can anyone give me a hint how to do this?

**Tags:** blockchain.info

> **Comments:**
> **username_1**: _What?_ could you rephrase?  
> **username_2**: This sounds a bit like an [XY problem](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). I'm guessing that you want to take payments, right?  
> **username_3**: Have you read through http://blockchain.info/api?  

---

## 2 answers

### Answer by username_4 on 2013-05-01. Score: 3

Get the block count:

```
http://blockchain.info/q/getblockcount

```

Subtract 3 from that number.

Get the transactions from the address you're looking for:

```
http://blockchain.info/address/$bitcoin_address?format=json&limit=50&offset=0

```

This returns 50 transactions by default, change the 'limit' value to wherever you might need it to be. Setting 'offset' to 5 will allow you to skip the first 5 transactions. Make sure you don't set offset to something greater than the total number of transactions on a particular address, it won't ever return anything.

Then set up your code to ignore any transaction that's newer than 3 blocks ago.


---

### Answer by username_5 on 2013-04-20. Score: 2

You can do this in two API calls, plus some filtering:

1. Get the current block height from `http://blockchain.info/latestblock`
2. Get the list of transactions for the address from `http://blockchain.info/address/$hash_160?format=json`
3. Filter transactions from #2 where the height is less than current block height minus 3.

Rough Ruby code:

```
require 'open-uri'
require 'json'
require 'pp'

desired_address = '1dice7W2AicHosf5EL3GFDUVga7TgtPFn' #high traffic address good for example code!
get_transactions_with_minimum_of_n_confirmations = 3

latestblock = JSON.parse open('http://blockchain.info/latestblock').read
address = JSON.parse open("http://blockchain.info/address/#{desired_address}?format=json").read

current_block_height = latestblock["height"]
pp address["txs"].select {|tx| tx["block_height"] < (current_block_height - get_transactions_with_minimum_of_n_confirmations) }

```

Keep in mind that you're going to retrieve a list of ALL transactions involving that address. It'd be nice of Blockchain.info let you specify a minimum number of confirmations to limit transactions to on the address call.


---

