getblockheader - Bitcoin
Example code for the getblockheader JSON-RPC method. Complete guide on how to use getblockheader JSON-RPC in GetBlock Web3 documentation.
Parameters
Parameter
Type
Required
Description
Request
curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "getblockheader",
"params": ["000000000000000000046b9302e08c16ea186950f42a5498320ddd1bd7ab3428", true],
"id": "getblock.io"
}'import axios from 'axios';
const data = JSON.stringify({
"jsonrpc": "2.0",
"method": "getblockheader",
"params": ["000000000000000000046b9302e08c16ea186950f42a5498320ddd1bd7ab3428", true],
"id": "getblock.io"
});
const config = {
method: 'post',
url: 'https://go.getblock.io/<ACCESS-TOKEN>/',
headers: {
'Content-Type': 'application/json'
},
data: data
};
axios(config)
.then(response => console.log(JSON.stringify(response.data)))
.catch(error => console.log(error));Response
{
"result": {
"hash": "0000000000000000000454a3a654c88ab5ad9824ca8506c1f7f65cc0ea193503",
"confirmations": 143923,
"height": 784665,
"version": 683581440,
"versionHex": "28bea000",
"merkleroot": "d8f4f9edd1c0a37a705289b7202a3d3b67ef46a20f88c27c88fe757aa87f17c5",
"time": 1681051849,
"mediantime": 1681049210,
"nonce": 2450381578,
"bits": "1705e0b2",
"difficulty": 47887764338536.25,
"chainwork": "000000000000000000000000000000000000000045155fb82c72a339d3522688",
"nTx": 169,
"previousblockhash": "00000000000000000003a77bfe6ccd653f7db680c4a03fa4b78ac95fa9dd5538",
"nextblockhash": "000000000000000000028b6ee09959abd8a47ce1487f3854fda0a7ed0b4e85ae"
},
"error": null
}Response Parameters
Field
Type
Description
Use Case
Error Handling
Status Code
Error Message
Cause
Integration Notes
Last updated
Was this helpful?