Skip to main content

getblockheader

Overview

The **'getblockheader'**PC method allows you to retrieve the header of a specific block using its hash.

Request

wget --no-check-certificate --quiet \
--method POST \
--timeout=0 \
--header 'Content-Type: application/json' \
--header 'accept: application/json' \
--header 'X-CoinAPI-Key: 73034021-THIS-IS-SAMPLE-KEY' \
--body-data '{
"jsonrpc": "1.0",
"id": "1",
"method": "getblockheader",
"params": []
}' \'https://bitcoin-mainnet.node.coinapi.io'

Request Parameters

blockhash (required)

  • Type: string
  • Description: The unique identifier of the block you want to query.

verbose (optional)

  • Type: boolean
  • Default: true
  • Description: When set to true, the method returns a JSON object. If set to false, it returns hex-encoded data

Response

For verbose = true:

  • hash: The hash identifier of the block.
  • confirmations: The number of confirmations the block has, or -1 if the block is not part of the main chain.
  • height: The height or index of the block in the blockchain.
  • version: The version number of the block.
  • versionHex: The version number of the block, formatted in hexadecimal.
  • merkleroot: The Merkle root of the block.
  • time: The time the block was created, expressed in UNIX epoch time.
  • mediantime: The median time of the block, also expressed in UNIX epoch time.
  • nonce: The nonce of the block.
  • bits: The value of the nBits field in the block header.
  • difficulty: An estimate of the amount of work required to find this block compared to the work required to find block 0.
  • chainwork: The expected number of hashes needed to produce the current chain.
  • nTx: The number of transactions included in the block.
  • previousblockhash: The hash of the preceding block, if available.
  • nextblockhash: The hash of the subsequent block, if available.
  • error: Any error messages encountered during the request.

For verbose = false:

  • result: A string containing serialized, hex-encoded data for the block hash.
  • error: Any error messages encountered during the request.