getblockstats - Bitcoin
Example code for the getblockstats JSON-RPC method. Complete guide on how to use getblockstats JSON-RPC in GetBlock Web3 documentation.
This method computes per-block statistics for a given block or block range.
Parameters
hash_or_height
string/number
Yes
The block hash or height.
stats
array
No
Array of stat names to retrieve. Returns all stats if not specified.
Request
curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "getblockstats",
"params": [820000, ["txs", "avgfee", "avgfeerate", "height", "time"]],
"id": "getblock.io"
}'import axios from 'axios';
const data = JSON.stringify({
"jsonrpc": "2.0",
"method": "getblockstats",
"params": [820000, ["txs", "avgfee", "avgfeerate", "height", "time"]],
"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
{
"jsonrpc": "2.0",
"id": "getblock.io",
"result": {
"avgfee": 25000,
"avgfeerate": 45,
"height": 820000,
"time": 1700000000,
"txs": 3500
}
}Response Parameters (Full Stats)
avgfee
number
Average fee per transaction (in satoshis).
avgfeerate
number
Average feerate (in sat/vB).
avgtxsize
number
Average transaction size.
blockhash
string
The block hash.
height
number
Block height.
ins
number
Total number of inputs.
maxfee
number
Maximum fee in the block.
maxfeerate
number
Maximum feerate in the block.
maxtxsize
number
Maximum transaction size.
medianfee
number
Median transaction fee.
mediantime
number
Block median time.
mediantxsize
number
Median transaction size.
minfee
number
Minimum fee in the block.
minfeerate
number
Minimum feerate in the block.
mintxsize
number
Minimum transaction size.
outs
number
Total number of outputs.
subsidy
number
Block subsidy (in satoshis).
swtotal_size
number
Total size of SegWit transactions.
swtotal_weight
number
Total weight of SegWit transactions.
swtxs
number
Number of SegWit transactions.
time
number
Block timestamp.
total_out
number
Total output value.
total_size
number
Total size of all transactions.
total_weight
number
Total weight of all transactions.
totalfee
number
Total fees in the block.
txs
number
Number of transactions.
utxo_increase
number
Change in UTXO set size.
utxo_size_inc
number
Change in UTXO set serialized size.
Use Case
The getblockstats method is essential for:
Block analysis and visualization
Fee market research
Transaction volume tracking
Mining profitability analysis
SegWit adoption monitoring
Building blockchain analytics dashboards
Error Handling
403
Forbidden
Missing or invalid ACCESS-TOKEN.
-3
Block not inputed
The block not inputed.
-8
Invalid stat name or Block not found
One of the requested stat names is invalid.
Integration Notes
The getblockstats method helps developers:
Build block analytics platforms
Create fee estimation models
Monitor SegWit adoption
Analyze transaction patterns
Track blockchain economics
Last updated
Was this helpful?