get_block_header_by_height - Monero
Example code for the get_block_header_by_height JSON-RPC method. Complete guide on how to use get_block_header_by_height JSON-RPC in GetBlock Web3 documentation.
This method returns the header of a block at a given height. Functionally similar to get_block_header_by_hash but indexed by height.
Parameters
height
unsigned int
Yes
Height of the block whose header to return
Request Example
curl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "get_block_header_by_height",
"params": {
"height": 912345
},
"id": "getblock.io"
}'import axios from 'axios';
const data = JSON.stringify({
"jsonrpc": "2.0",
"method": "get_block_header_by_height",
"params": {
"height": 912345
},
"id": "getblock.io"
});
const config = {
method: 'post',
url: 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
headers: {
'Content-Type': 'application/json'
},
data: data
};
axios(config)
.then(response => console.log(JSON.stringify(response.data, null, 2)))
.catch(error => console.log(error));Response Example
{
"id": "getblock.io",
"jsonrpc": "2.0",
"result": {
"block_header": {
"block_size": 5500,
"depth": 100,
"difficulty": 294558564173,
"hash": "e22cf75f39ae720e8b71b3d120a5ac03f0db50bba6379e2850975b4859190bc6",
"height": 912345,
"major_version": 7,
"minor_version": 7,
"nonce": 1234567890,
"num_txes": 12,
"orphan_status": false,
"prev_hash": "37155cae7d3aa8ca7dc8b9e69e0d1f64b5e3a8b1c2d9e4f5a6b7c8d9e0f1a2b3",
"reward": 1500000000000,
"timestamp": 1452793716
},
"status": "OK",
"untrusted": false
}
}Response Parameters
result.block_header.height
unsigned int
Block height (echoed back)
result.block_header.hash
string
Block hash at this height
result.block_header.timestamp
unsigned int
Unix timestamp
result.block_header.reward
unsigned int
Coinbase reward in atomic units
Use Cases
Resolving header metadata from a known height
Block-by-block iteration in indexers
Computing block-time intervals
Error Handling
403
Forbidden
Missing or invalid <ACCESS-TOKEN>
-32602
Invalid params
Request parameters are missing or malformed
429
Too Many Requests
Rate limit exceeded for your plan
SDK Integration
Last updated
Was this helpful?