<p>If you looking for a simple web API, the most popular choice is Blockfrost:
<a href="https://docs.blockfrost.io/#tag/Cardano-Blocks/paths/%7E1blocks%7E1%7Bhash_or_number%7D/get" rel="nofollow noreferrer">https://docs.blockfrost.io/#tag/Cardano-Blocks/paths/~1blocks~1%7Bhash_or_number%7D/get</a>
<a href="https://docs.blockfrost.io/#tag/Cardano-Blocks/paths/%7E1blocks%7E1latest/get" rel="nofollow noreferrer">https://docs.blockfrost.io/#tag/Cardano-Blocks/paths/~1blocks~1latest/get</a></p>
<p>which has a generous free tier.
An alternative is Koios:
<a href="https://api.koios.rest/#overview" rel="nofollow noreferrer">https://api.koios.rest/#overview</a></p>
<p>If you want to run some infrastructure yourself, have a look at:</p>
<p>Ogmois: <a href="https://ogmios.dev/" rel="nofollow noreferrer">https://ogmios.dev/</a>
or Oura: <a href="https://github.com/txpipe/oura" rel="nofollow noreferrer">https://github.com/txpipe/oura</a></p>
<p>specifically to get the latest block/live data and</p>
<p>cardano-db-sync (<a href="https://github.com/input-output-hk/cardano-db-sync" rel="nofollow noreferrer">https://github.com/input-output-hk/cardano-db-sync</a>)
or carp (<a href="https://github.com/dcSpark/carp" rel="nofollow noreferrer">https://github.com/dcSpark/carp</a>)</p>
<p>to query the whole chain.</p>

CC BY-SA 4.0
2023-02-06T22:54:25.903Z
2023-02-06T22:54:25.903Z
DaveStrider
<p>This is a relatively simple query against <code>cardano-db-sync</code>.</p>

CC BY-SA 4.0
2023-02-06T23:01:24.107Z
2023-02-06T23:01:24.107Z
Erik de Castro Lopo
<p>Using <a href="https://blockfrost.io/" rel="nofollow noreferrer">Blockfrost.io</a> API:</p>
<ol>
<li>For transaction hash <code>dbbf5116280f83bb6d3d117ef0b41ca52b0bb85f417f761bd42d1903286743e6</code>:</li>
</ol>
<p>You can find the block height:</p>
<pre><code> $ curl -s https://cardano-mainnet.blockfrost.io/api/v0/txs/dbbf5116280f83bb6d3d117ef0b41ca52b0bb85f417f761bd42d1903286743e6 -H 'project_id: xxx' \
  | jq .block_height
8369736
</code></pre>
<p>And use that block height to get more information about the given block.</p>
<pre><code>$ curl -s https://cardano-mainnet.blockfrost.io/api/v0/blocks/8369736 -H 'project_id: x'  | jq
{
  &quot;time&quot;: 1675778106,
  &quot;height&quot;: 8369736,
  &quot;hash&quot;: &quot;0fa8c39c9c30ebb14b64781cca63d326a3c57154dfb590d63c0d3eb7850cc4ec&quot;,
  &quot;slot&quot;: 84211815,
  &quot;epoch&quot;: 392,
  &quot;epoch_slot&quot;: 231015,
  &quot;slot_leader&quot;: &quot;pool1q7wrwstqkzhrffdzpw8ftfd4epmxywdjnp8384atjcnezchv242&quot;,
  &quot;size&quot;: 88902,
  &quot;tx_count&quot;: 35,
  &quot;output&quot;: &quot;22093283458254&quot;,
  &quot;fees&quot;: &quot;11180120&quot;,
  &quot;block_vrf&quot;: &quot;vrf_vk1uatrt2xzhxs382ss5u9mr20aahzx8s000c077xerulzy22dzxy3qc0r6qv&quot;,
  &quot;op_cert&quot;: &quot;9c6689a625fb22cd17df084718f232155a15a73b56103a96a117e5d4a58f95a8&quot;,
  &quot;op_cert_counter&quot;: &quot;10&quot;,
  &quot;previous_block&quot;: &quot;055462536b48a16b91552ff05df0760d2191c044ec419f2f93d9c7a894aaecde&quot;,
  &quot;next_block&quot;: &quot;f63f3ed7140524bffc1a975a177f93cf72b426201f9ea5a82cb059a7ed1b53df&quot;,
  &quot;confirmations&quot;: 10
}
</code></pre>
<ol start="2">
<li>For the current block number, just use <code>/api/v0/blocks/latest</code>.</li>
</ol>

CC BY-SA 4.0
2023-02-07T14:00:15.003Z
2023-02-07T14:00:15.003Z
Marek Mahut - StakeNuts
<p>Is there any API for this out already?</p>
<p>I'm looking for an API that:</p>
<ol>
<li>Given a tx hash, can get the block # and info about the block which the transaction was in</li>
<li>get current block # and info about current block</li>
</ol>

<cardano-node>
Given tx hash, get block # and info about block the transaction is in
# Given tx hash, get block # and info about block the transaction is in

(Asked by: username_0 on 2023-02-06)

Is there any API for this out already?

I'm looking for an API that:

1. Given a tx hash, can get the block # and info about the block which the transaction was in
2. get current block # and info about current block

**Tags:** cardano-node

---

## 3 answers

### Answer by username_3 on 2023-02-07. Score: 1 | Accepted answer

Using Blockfrost.io API:

For transaction hash dbbf5116280f83bb6d3d117ef0b41ca52b0bb85f417f761bd42d1903286743e6:

You can find the block height:
 $ curl -s https://cardano-mainnet.blockfrost.io/api/v0/txs/dbbf5116280f83bb6d3d117ef0b41ca52b0bb85f417f761bd42d1903286743e6 -H 'project_id: xxx' \
  | jq .block_height
8369736

And use that block height to get more information about the given block.
$ curl -s https://cardano-mainnet.blockfrost.io/api/v0/blocks/8369736 -H 'project_id: x'  | jq
{
  "time": 1675778106,
  "height": 8369736,
  "hash": "0fa8c39c9c30ebb14b64781cca63d326a3c57154dfb590d63c0d3eb7850cc4ec",
  "slot": 84211815,
  "epoch": 392,
  "epoch_slot": 231015,
  "slot_leader": "pool1q7wrwstqkzhrffdzpw8ftfd4epmxywdjnp8384atjcnezchv242",
  "size": 88902,
  "tx_count": 35,
  "output": "22093283458254",
  "fees": "11180120",
  "block_vrf": "vrf_vk1uatrt2xzhxs382ss5u9mr20aahzx8s000c077xerulzy22dzxy3qc0r6qv",
  "op_cert": "9c6689a625fb22cd17df084718f232155a15a73b56103a96a117e5d4a58f95a8",
  "op_cert_counter": "10",
  "previous_block": "055462536b48a16b91552ff05df0760d2191c044ec419f2f93d9c7a894aaecde",
  "next_block": "f63f3ed7140524bffc1a975a177f93cf72b426201f9ea5a82cb059a7ed1b53df",
  "confirmations": 10
}


For the current block number, just use /api/v0/blocks/latest.


---

### Answer by username_1 on 2023-02-06. Score: 2

If you looking for a simple web API, the most popular choice is Blockfrost:
[https://docs.blockfrost.io/#tag/Cardano-Blocks/paths/~1blocks~1%7Bhash\_or\_number%7D/get](https://docs.blockfrost.io/#tag/Cardano-Blocks/paths/%7E1blocks%7E1%7Bhash_or_number%7D/get)
[https://docs.blockfrost.io/#tag/Cardano-Blocks/paths/~1blocks~1latest/get](https://docs.blockfrost.io/#tag/Cardano-Blocks/paths/%7E1blocks%7E1latest/get)

which has a generous free tier.
An alternative is Koios:
<https://api.koios.rest/#overview>

If you want to run some infrastructure yourself, have a look at:

Ogmois: <https://ogmios.dev/>
or Oura: <https://github.com/txpipe/oura>

specifically to get the latest block/live data and

cardano-db-sync (<https://github.com/input-output-hk/cardano-db-sync>)
or carp (<https://github.com/dcSpark/carp>)

to query the whole chain.


---

### Answer by username_2 on 2023-02-06. Score: 1

This is a relatively simple query against `cardano-db-sync`.


---

