<p>Almost all block explorer APIs have this functionality among their transaction API calls. You should check out their API documentation for more details and see which one is easier for you to use.<br>
Here is an example from blockcypher API using the first non-coinbase transaction of one of the latest blocks:<br>
<a href="https://api.blockcypher.com/v1/btc/main/txs/ca1662e85e137fae3ec13dace7f4bf64801a1ebdc8433150566b2ae838498a8a" rel="nofollow noreferrer">https://api.blockcypher.com/v1/btc/main/txs/ca1662e85e137fae3ec13dace7f4bf64801a1ebdc8433150566b2ae838498a8a</a><br>
Response:  </p>

<pre><code>{
  ...
  "confirmations": 2,
  ...
}
</code></pre>

<p>If the transaction is still in the mempool (unconfirmed) the value above shows as <code>0</code>.  </p>

<p>Note that if the purpose is unimportant things such as showing donations using a block explorer is fine, otherwise if the purpose is receiving payments (eg. for a sale) it is a much better idea to use a different method such as running your own full or SPV node.</p>

CC BY-SA 4.0
2020-04-08T05:49:39.797Z
2020-04-08T05:49:39.797Z
Coding Enthusiast
<p>To answer your question specifically:</p>
<ul>
<li>ideally query your own Bitcoin full node with <code>gettransaction</code> (possible if you can at least import xpubs to watch only wallets)</li>
<li>query public block explorers</li>
<li>query public Electrum servers</li>
</ul>
<p>On a broader note though, your problem seems to be already solved by open source tools like <a href="https://btcpayserver.org/" rel="nofollow noreferrer">BTCPay Server</a> or <a href="https://cypherpunkpay.org/" rel="nofollow noreferrer">CypherpunkPay</a>.</p>

CC BY-SA 4.0
2021-06-25T09:28:49.640Z
2021-06-25T09:28:49.640Z
CypherpunkDev
<p>To detect transaction status in JSON format for the given bitcoin address on blockchain.info, you can follow these steps:</p>
<p>Send a GET request to the following URL: <a href="https://blockchain.info/address/157vxTThwznZQPGmUuSzqGci5DCZAdRDap?format=json" rel="nofollow noreferrer">https://blockchain.info/address/157vxTThwznZQPGmUuSzqGci5DCZAdRDap?format=json</a></p>
<p>This will return a JSON object containing information about the given Bitcoin address, including the transactions associated with it. Look for the &quot;txs&quot; field in the JSON response.</p>
<p>The &quot;txs&quot; field contains an array of transaction objects. Each transaction object contains a &quot;hash&quot; field that uniquely identifies the transaction, as well as a &quot;confirmations&quot; field that indicates the number of confirmations the transaction has received. A confirmation occurs when a new block is added to the blockchain that includes the transaction.</p>
<p>If the value of the &quot;confirmations&quot; field is zero, the transaction is unconfirmed and its status is pending. If the value is greater than zero, the transaction is confirmed and its status is completed.</p>
<p>So, to detect the transaction status, you need to check the &quot;confirmations&quot; field of each transaction object in the &quot;txs&quot; field. If the &quot;confirmations&quot; field is zero, the transaction is unconfirmed, otherwise, it's confirmed.</p>
<ul>
<li>If you don't have &quot;confirmations&quot; in response. Check &quot;block_height&quot;, If not present or null the result is unconfirmed and it's present and has number the result is confirmed.</li>
</ul>

CC BY-SA 4.0
2023-06-21T05:22:57.077Z
This should be the accepted answer. I should also add that to get the number of confirms itself, fetch the latest block height from blockchain.info and subtract block_height from it, then add 1. (confirmations field is no longer returned in the API it seems).
Zenul_Abidin
CC BY-SA 4.0
2023-06-20T06:54:09.717Z
2023-06-20T07:29:09.637Z
2023-06-20T07:29:09.637Z
reza_khalafi
<p>My team is working for a community of members who make donations in <code>BTC</code> to support a cause from time to time. The donations the details are stored in a <code>database</code> and displayed on their personal profiles.</p>

<p>I am currently looking out for an <code>api</code> that will give me an information about the status of a particular transaction. i.e. whether or not the transaction is confirmed.   </p>

CC BY-SA 4.0
2023-06-20T06:09:27.010Z
Did you find any answer?
reza_khalafi
<blockchain><api>
Api to automatically check the status of a BTC transaction
mamaye
# Api to automatically check the status of a BTC transaction

(Asked by: username_0 on 2020-04-07)

My team is working for a community of members who make donations in `BTC` to support a cause from time to time. The donations the details are stored in a `database` and displayed on their personal profiles.

I am currently looking out for an `api` that will give me an information about the status of a particular transaction. i.e. whether or not the transaction is confirmed.

**Tags:** blockchain, api

> **Comments:**
> **username_1**: Did you find any answer?  

---

## 3 answers

### Answer by username_2 on 2020-04-08. Score: 1

Almost all block explorer APIs have this functionality among their transaction API calls. You should check out their API documentation for more details and see which one is easier for you to use.  
Here is an example from blockcypher API using the first non-coinbase transaction of one of the latest blocks:  
<https://api.blockcypher.com/v1/btc/main/txs/ca1662e85e137fae3ec13dace7f4bf64801a1ebdc8433150566b2ae838498a8a>  
Response:

```
{
  ...
  "confirmations": 2,
  ...
}

```

If the transaction is still in the mempool (unconfirmed) the value above shows as `0`.

Note that if the purpose is unimportant things such as showing donations using a block explorer is fine, otherwise if the purpose is receiving payments (eg. for a sale) it is a much better idea to use a different method such as running your own full or SPV node.


---

### Answer by username_3 on 2021-06-25. Score: 1

To answer your question specifically:

* ideally query your own Bitcoin full node with `gettransaction` (possible if you can at least import xpubs to watch only wallets)
* query public block explorers
* query public Electrum servers

On a broader note though, your problem seems to be already solved by open source tools like [BTCPay Server](https://btcpayserver.org/) or [CypherpunkPay](https://cypherpunkpay.org/).


---

### Answer by username_1 on 2023-06-20. Score: 0

To detect transaction status in JSON format for the given bitcoin address on blockchain.info, you can follow these steps:

Send a GET request to the following URL: <https://blockchain.info/address/157vxTThwznZQPGmUuSzqGci5DCZAdRDap?format=json>

This will return a JSON object containing information about the given Bitcoin address, including the transactions associated with it. Look for the "txs" field in the JSON response.

The "txs" field contains an array of transaction objects. Each transaction object contains a "hash" field that uniquely identifies the transaction, as well as a "confirmations" field that indicates the number of confirmations the transaction has received. A confirmation occurs when a new block is added to the blockchain that includes the transaction.

If the value of the "confirmations" field is zero, the transaction is unconfirmed and its status is pending. If the value is greater than zero, the transaction is confirmed and its status is completed.

So, to detect the transaction status, you need to check the "confirmations" field of each transaction object in the "txs" field. If the "confirmations" field is zero, the transaction is unconfirmed, otherwise, it's confirmed.

* If you don't have "confirmations" in response. Check "block\_height", If not present or null the result is unconfirmed and it's present and has number the result is confirmed.

> **Comments:**
> **username_4**: This should be the accepted answer. I should also add that to get the number of confirms itself, fetch the latest block height from blockchain.info and subtract block_height from it, then add 1. (confirmations field is no longer returned in the API it seems).  

---

