Skip to main content

getblockcount

Overview

The 'getblockcount' RPC method in the CoinAPI allows you to retrieve the height of the fully-validated blockchain. The genesis block, which is the first block in the blockchain, has a height of 0. This method is essential for users who want to track the current length of the blockchain.

Request

wget --no-check-certificate --quiet \
--method POST \
--timeout=0 \
--header 'Content-Type: application/json' \
--header 'accept: application/json' \
--header 'X-CoinAPI-Key: 4303fb63-adec-42dc-b571-74bc2f2a5167' \
--body-data '{"jsonrpc":"2.0","id":1,"method":"getblockcount","params": [ ]}' \
'https://bitcoin-mainnet.node.coinapi.io'

Request Parameters

This method does not require any parameters.

Response

{
"result": 810358,
"error": null,
"id": 1
}
  • result: This field will contain the current block count, representing the height of the blockchain.
  • error: In case of an error, this field will contain the respective error message, if any.