<p>If you are using php, then try this :</p>

<pre><code>function response ($result) {   
      header("Content-Type:application/json");
      $response['confirmation'] = $result;
      $json_response = json_encode($response);
      echo $json_response;
  }


$tx_hash  = '5e910a5b61e3ccdb7...'; // try to get a new tx hash from blockchain.info/.com

$bcinfo = json_decode(file_get_contents("https://blockchain.info/rawtx/".$tx_hash), true);
$latest = json_decode(file_get_contents("https://blockchain.info/latestblock"), true);

if(isset($bcinfo['block_height'])) {

   $block_height =  $bcinfo['block_height'];
   $height       =  $latest['height'];

   response($height - $block_height + 1);

}else{

   response(0); // not yet has any confirmations

}
</code></pre>

CC BY-SA 4.0
2018-11-17T00:18:29.370Z
2018-11-17T00:18:29.370Z
Sulung Nugroho
<p>Confirmations for an address aren't really a thing.  Addresses are not confirmed; <em>transactions</em> are.  A single address is typically used in multiple transactions: one where the address is used as an output, and one where the first transaction was used as an input.  Although it's not a best practice, addresses can even be re-used multiple times.</p>

<p>It looks like this particular address has been used in two different transactions.  Once as an output in <a href="https://blockchain.info/tx/00c83c7677d414053488d0b51067feee157a5b82d5acec5bfe8e9c540c11c624" rel="nofollow noreferrer">00c83c7677d414053488d0b51067feee157a5b82d5acec5bfe8e9c540c11c624</a>, and once as in input in <a href="https://blockchain.info/tx/378f829160cb9c99cc7a8fb1152472b80f0e1ea9c9cc24118dbccc2da72dedcf" rel="nofollow noreferrer">378f829160cb9c99cc7a8fb1152472b80f0e1ea9c9cc24118dbccc2da72dedcf</a>.</p>

<p>Each of these two transactions returned in the API response has a <code>block_height</code> value (<code>489353</code> and <code>489355</code>).  That is the block at which the transaction was included.  To find how many confirmations each transaction has, subtract the <code>block_height</code> by the height of the most recently confirmed block, and add 1.  So if the current block is <code>489355</code>, one transaction has 1 confirmation, and the other has 3.</p>

CC BY-SA 3.0
2017-10-11T17:19:18.837Z
2017-10-11T17:19:18.837Z
Jestin
<p>How can I check <strong>confirmations number</strong> for some bitcoin address programmatically? (I have eCommerce shop where each order has separate address).
I want to use blockchain.info API.</p>

<p>Here is an example of the API call, but I can't figure out what numbers should I check in API response:</p>

<p><a href="https://blockchain.info/rawaddr/1JbBiCzQqzE2dW9TCzA6w7N27jVDXxwreD" rel="nofollow noreferrer">https://blockchain.info/rawaddr/1JbBiCzQqzE2dW9TCzA6w7N27jVDXxwreD</a></p>

<blockchain.info><api>
How to check confirmations number programmatically
Roman Snitko
# How to check confirmations number programmatically

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

How can I check **confirmations number** for some bitcoin address programmatically? (I have eCommerce shop where each order has separate address).
I want to use blockchain.info API.

Here is an example of the API call, but I can't figure out what numbers should I check in API response:

<https://blockchain.info/rawaddr/1JbBiCzQqzE2dW9TCzA6w7N27jVDXxwreD>

**Tags:** blockchain.info, api


---

## 2 answers

### Answer by username_2 on 2017-10-11. Score: 4 | Accepted answer

Confirmations for an address aren't really a thing. Addresses are not confirmed; *transactions* are. A single address is typically used in multiple transactions: one where the address is used as an output, and one where the first transaction was used as an input. Although it's not a best practice, addresses can even be re-used multiple times.

It looks like this particular address has been used in two different transactions. Once as an output in [00c83c7677d414053488d0b51067feee157a5b82d5acec5bfe8e9c540c11c624](https://blockchain.info/tx/00c83c7677d414053488d0b51067feee157a5b82d5acec5bfe8e9c540c11c624), and once as in input in [378f829160cb9c99cc7a8fb1152472b80f0e1ea9c9cc24118dbccc2da72dedcf](https://blockchain.info/tx/378f829160cb9c99cc7a8fb1152472b80f0e1ea9c9cc24118dbccc2da72dedcf).

Each of these two transactions returned in the API response has a `block_height` value (`489353` and `489355`). That is the block at which the transaction was included. To find how many confirmations each transaction has, subtract the `block_height` by the height of the most recently confirmed block, and add 1. So if the current block is `489355`, one transaction has 1 confirmation, and the other has 3.


---

### Answer by username_1 on 2018-11-17. Score: 1

If you are using php, then try this :

```
function response ($result) {   
      header("Content-Type:application/json");
      $response['confirmation'] = $result;
      $json_response = json_encode($response);
      echo $json_response;
  }

$tx_hash  = '5e910a5b61e3ccdb7...'; // try to get a new tx hash from blockchain.info/.com

$bcinfo = json_decode(file_get_contents("https://blockchain.info/rawtx/".$tx_hash), true);
$latest = json_decode(file_get_contents("https://blockchain.info/latestblock"), true);

if(isset($bcinfo['block_height'])) {

   $block_height =  $bcinfo['block_height'];
   $height       =  $latest['height'];

   response($height - $block_height + 1);

}else{

   response(0); // not yet has any confirmations

}

```


---

