Ask or search…
K
Links

getblockstats

How to use it

TypeScript/JavaScript
1
// yarn add @tatumio/tatum
2
3
import { TatumSDK, Bitcoin, Network } from '@tatumio/tatum'
4
5
const tatum = await TatumSDK.init<Bitcoin>({network: Network.BITCOIN})
6
7
const result = await tatum.rpc.getBlockStats("0000000000000000001b4fedbfb3672963c37f965686c2bf6350e32e77f9941f")
8
9
await tatum.destroy() // Destroy Tatum SDK - needed for stopping background jobs

Overview

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.
Try this function

Parameters

  • 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"]

Return Object

The return object is a JSON object containing the requested statistics as key-value pairs. The available statistics are:
  • avgfee: The average transaction fee in satoshis.
  • avgfeerate: The average fee rate in satoshis per virtual byte.
  • avgtxsize: The average transaction size in bytes.
  • blockhash: The hash of the block.
  • height: The height of the block in the block chain.
  • ins: The total number of inputs in all transactions.
  • maxfee: The maximum transaction fee in satoshis.
  • maxfeerate: The maximum fee rate in satoshis per virtual byte.
  • maxtxsize: The maximum transaction size in bytes.
  • medianfee: The median transaction fee in satoshis.
  • mediantime: The median time for the block in UNIX timestamp format.
  • mediantxsize: The median transaction size in bytes.
  • minfee: The minimum transaction fee in satoshis.
  • minfeerate: The minimum fee rate in satoshis per virtual byte.
  • mintxsize: The minimum transaction size in bytes.
  • outs: The total number of outputs in all transactions.
  • subsidy: The block reward in satoshis.
  • swtotal_size: The total size of all SegWit transactions in bytes.
  • swtotal_weight: The total weight of all SegWit transactions.
  • swtxs: The total number of SegWit transactions.
  • time: The block timestamp in UNIX format.
  • total_size: The total size of all transactions in bytes.
  • total_weight: The total weight of all transactions.
  • totalfee: The total transaction fees in satoshis.
  • txs: The total number of transactions in the block.
  • utxo_increase: The increase in the number of unspent transaction outputs.
  • utxo_size_inc: The increase in the size of the UTXO set.

JSON Examples

Request example:
1
{
2
"jsonrpc": "2.0",
3
"method": "getblockstats",
4
"params": ["0000000000000000001b4fedbfb3672963c37f965686c2bf6350e32e77f9941f"],
5
"id": 1
6
}
Response example:
1
{
2
"result": {
3
"avgfee": 10220,
4
"avgfeerate": 18,
5
"avgtxsize": 619,
6
"blockhash": "0000000000000000001b4fedbfb3672963c37f965686c2bf6350e32e77f9941f",
7
"feerate_percentiles": [
8
6,
9
9,
10
9,
11
15,
12
48
13
],
14
"height": 587123,
15
"ins": 3615,
16
"maxfee": 419448,
17
"maxfeerate": 393,
18
"maxtxsize": 17196,
19
"medianfee": 9528,
20
"mediantime": 1564151358,
21
"mediantxsize": 374,
22
"minfee": 136,
23
"minfeerate": 1,
24
"mintxsize": 189,
25
"outs": 3617,
26
"subsidy": 1250000000,
27
"swtotal_size": 323742,
28
"swtotal_weight": 777804,
29
"swtxs": 616,
30
"time": 1564152126,
31
"total_out": 342467209172,
32
"total_size": 1127251,
33
"total_weight": 3991840,
34
"totalfee": 18590521,
35
"txs": 1820,
36
"utxo_increase": 2,
37
"utxo_size_inc": 4000
38
},
39
"error": null,
40
"id": 1
41
}
\
© Tatum Technology, LLC