π Get Bitcoin block by height
Code samples
GET /api/v1/btc/block/{blockNumber}
Returns a specific block by its height using getblockhash followed by getblock with verbosity 2.
π οΈ Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| blockNumber | path | integer(int64) | true | Block height in the best chain (non-negative integer). |
Example responses
200 Response
{
"hash": "string",
"confirmations": 0,
"height": 0,
"version": 0,
"versionHex": "string",
"merkleroot": "string",
"time": 0,
"mediantime": 0,
"nonce": 0,
"bits": "string",
"difficulty": 0.1,
"chainwork": "string",
"nTx": 0,
"strippedsize": 0,
"size": 0,
"weight": 0,
"previousblockhash": "string",
"nextblockhash": "string",
"tx": [
"string"
]
}
400 Response
{
"error": "Block number must be non-negative"
}
π Responses
| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | Bitcoin block | Inline |
| 400 | Bad Request | Invalid block number (negative) | Inline |
| 500 | Internal Server Error | Could not connect to BTC node | None |
π Response Schema
Status Code 200
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| Β» hash | string | false | none | Hash of the block. |
| Β» confirmations | integer(int64) | false | none | Number of confirmations for the block. |
| Β» height | integer(int64) | false | none | Block height. |
| Β» version | integer | false | none | Block version. |
| Β» versionHex | string | false | none | none |
| Β» merkleroot | string | false | none | Merkle root of the block's transactions. |
| Β» time | integer(int64) | false | none | Block time in seconds since Unix epoch. |
| Β» mediantime | integer(int64) | false | none | none |
| Β» nonce | integer(int64) | false | none | none |
| Β» bits | string | false | none | none |
| Β» difficulty | number(double) | false | none | none |
| Β» chainwork | string | false | none | none |
| Β» nTx | integer(int64) | false | none | Number of transactions in the block. |
| Β» strippedsize | integer(int64) | false | none | none |
| Β» size | integer(int64) | false | none | none |
| Β» weight | integer(int64) | false | none | none |
| » previousblockhash | string¦null | false | none | none |
| » nextblockhash | string¦null | false | none | none |
| Β» tx | array | false | none | Transactions included in the block. When verbosity=2, this is an array of full transaction objects; otherwise it may be an array of transaction IDs. |
Status Code 400
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| Β» error | string | false | none | none |