getblockstats

Bitcoin RPC

Overview

The getblockstats is a Bitcoin RPC method that returns various statistics about a specified block. This method is useful for obtaining detailed information about a block, including the number of transactions, transaction volume, fees, and other related data. The results can be used for data analysis, monitoring, and understanding the state of the Bitcoin network at a specific block height.

Parameters

  • blockhash: The hash of the block for which the header information is requested. This is a string parameter.
    • Example: "0000000000000000000ef0e1f703b56f2b0d6724e4eeccf00e4f8d55b9c3c3f6e"
  • verbose: A boolean parameter that specifies whether to return the header information in a JSON object (true) or as a serialized hex-encoded string (false). Default is true.
    • Example: True
    • hash_or_height: The block hash or block height for which the statistics are requested. This parameter can be either a string (block hash) or an integer (block height).
      • Example (block hash): "0000000000000000000f92fb968a8d1a2a9c2039e6e99f8c7a0ee3421a44a7d6"
      • Example (block height): 685230
    • stats (optional): An array of strings indicating the statistics to be included in the response. If not specified, all available statistics will be returned.
      • Example: ["txs", "avgfee"]

Returns

The return object is a JSON object containing the requested statistics as key-value pairs. The available statistics are:

NameDescription
avgfeeThe average transaction fee in satoshis.
avgfeerateThe average fee rate in satoshis per virtual byte.
avgtxsizeThe average transaction size in bytes.
blockhashThe hash of the block.
heightThe height of the block in the block chain.
insThe total number of inputs in all transactions.
maxfeeThe maximum transaction fee in satoshis.
maxfeerateThe maximum fee rate in satoshis per virtual byte.
maxtxsizeThe maximum transaction size in bytes.
medianfeeThe median transaction fee in satoshis.
mediantimeThe median time for the block in UNIX timestamp format.
mediantxsizeThe median transaction size in bytes.
minfeeThe minimum transaction fee in satoshis.
minfeerateThe minimum fee rate in satoshis per virtual byte.
mintxsizeThe minimum transaction size in bytes.
outsThe total number of outputs in all transactions.
subsidyThe block reward in satoshis.
swtotal_sizeThe total size of all SegWit transactions in bytes.
swtotal_weightThe total weight of all SegWit transactions.
swtxsThe total number of SegWit transactions.
timeThe block timestamp in UNIX format.
total_sizeThe total size of all transactions in bytes.
total_weightThe total weight of all transactions.
totalfeeThe total transaction fees in satoshis.
txsThe total number of transactions in the block.
utxo_increaseThe increase in the number of unspent transaction outputs.
utxo_size_incThe increase in the size of the UTXO set.

If verbose is set to false, the return object is a serialized hex-encoded string of the block header.

Request Example

curl --location 'https://api.tatum.io/v3/blockchain/node/bitcoin-mainnet/' \
--header 'Content-Type: application/json' \
--header 'x-api-key: {API_KEY}' \
--data '{{
  "jsonrpc": "2.0",
  "method": "getblockstats",
  "params": ["0000000000000000001b4fedbfb3672963c37f965686c2bf6350e32e77f9941f"],
  "id": 1
}'
// yarn add @tatumio/tatum

import { TatumSDK, Bitcoin, Network } from '@tatumio/tatum'

const tatum = await TatumSDK.init<Bitcoin>({network: Network.BITCOIN})

const result = await tatum.rpc.getBlockStats("0000000000000000001b4fedbfb3672963c37f965686c2bf6350e32e77f9941f")

await tatum.destroy() // Destroy Tatum SDK - needed for stopping background jobs