<blockquote>
  <p>but maybe one could use the block height to match the tx to the block?</p>
</blockquote>

<p>Indeed that would work fine, <code>block_height</code> is returned by the /rawtx/ call (<a href="https://blockchain.info/rawtx/" rel="nofollow noreferrer">https://blockchain.info/rawtx/</a>$tx_hash) for transactions that have been included in a block (unconfirmed transactions have no block_height key). Then you can find the block hash and/or information about the block with the /block-height/ call (<a href="https://blockchain.info/block-height/" rel="nofollow noreferrer">https://blockchain.info/block-height/</a>$block_height?format=json)</p>

CC BY-SA 3.0
2017-11-02T18:04:30.580Z
Would you mind trying tx hash: 4c1df235ffd7642008989422aee5255e6312b4172b55d94e328fa99e99d727c7 on https://www.smartbit.com.au/api just as a sanity check because I don't see the tx come up on the block it's supposed to...
timothyylim
CC BY-SA 3.0
2017-11-02T06:57:43.360Z
2017-11-02T06:57:43.360Z
meshcollider
<p>I'm using Blockchain.info's api:</p>

<p><a href="https://blockchain.info/api/blockchain_api" rel="nofollow noreferrer">https://blockchain.info/api/blockchain_api</a></p>

<p>I understand that it is impossible for a transaction to know which block it will be included in but maybe one could use the block height to match the tx to the block? </p>

<transactions><blockchain.info><api>
Given a transaction hash, how do you get the block the transaction was included in?
timothyylim
# Given a transaction hash, how do you get the block the transaction was included in?

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

I'm using Blockchain.info's api:

<https://blockchain.info/api/blockchain_api>

I understand that it is impossible for a transaction to know which block it will be included in but maybe one could use the block height to match the tx to the block?

**Tags:** transactions, blockchain.info, api


---

## 1 answers

### Answer by username_1 on 2017-11-02. Score: 1

> but maybe one could use the block height to match the tx to the block?

Indeed that would work fine, `block_height` is returned by the /rawtx/ call (<https://blockchain.info/rawtx/>$tx\_hash) for transactions that have been included in a block (unconfirmed transactions have no block\_height key). Then you can find the block hash and/or information about the block with the /block-height/ call (<https://blockchain.info/block-height/>$block\_height?format=json)

> **Comments:**
> **username_0**: Would you mind trying tx hash: 4c1df235ffd7642008989422aee5255e6312b4172b55d94e328fa99e99d727c7 on https://www.smartbit.com.au/api just as a sanity check because I don't see the tx come up on the block it's supposed to...  

---

