rest/block - Bitcoin

This endpoint returns a block with every transaction decoded in full. The same block is available as raw hex at .hex and as raw binary at .bin.

Parameters

ParameterTypeLocationRequiredDescription
hashstringpathYesThe block hash
formatstringpathYesResponse format appended to the hash: json, hex, or bin

Request

bashcurl --location --request GET 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/rest/block/000000000000000000019c481c042c0625abe1dc04fe26795e2e24b152791e5f.json'

example.js

javascriptconst response = await fetch(
    'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/rest/block/000000000000000000019c481c042c0625abe1dc04fe26795e2e24b152791e5f.json'
);
console.log(await response.json());

example.py

pythonimport requests

response = requests.get('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/rest/block/000000000000000000019c481c042c0625abe1dc04fe26795e2e24b152791e5f.json')

print(response.json())

Response

json{
    "hash": "000000000000000000019c481c042c0625abe1dc04fe26795e2e24b152791e5f",
    "confirmations": 1,
    "height": 967816,
    "version": 617037824,
    "merkleroot": "7b7ffdc51c5adbc40f8c209747b7c82f083f647e555cd0ef80b8acf66df21ebf",
    "time": 1789899076,
    "nonce": 1539191330,
    "bits": "17021ec5",
    "difficulty": 132757073449487.5,
    "nTx": 4131,
    "previousblockhash": "0000000000000000000159d94328a0362aba4418de918cba6830e550f8e50bd8",
    "strippedsize": 800904,
    "size": 1590347,
    "weight": 3993059,
    "tx": [
        {
            "txid": "98bde4a7f407769028cbe725695d388324ab6b83fab4f310005082dd9b8b2de9",
            "hash": "290ba098c730ca593384647c6c55f4233a60fbdaa9055fd1fe54f51f49a30ad0",
            "version": 2,
            "size": 205,
            "vsize": 154,
            "weight": 616,
            "locktime": 0,
            "vin": [
                "..."
            ],
            "vout": [
                "..."
            ],
            "hex": "02000000000101..."
        }
    ]
}

The tx array is truncated to one transaction, with its inputs and outputs elided; this block holds 4,131.

Response Parameters

FieldTypeDescription
hashstringThe block hash
confirmationsnumericDepth of the block, or -1 if not on the main chain
heightnumericBlock height
versionnumericBlock version
versionHexstringBlock version in hex
merklerootstringMerkle root of the block's transactions
timenumericBlock time as a Unix timestamp
mediantimenumericMedian time of the preceding 11 blocks
noncenumericProof-of-work nonce
bitsstringCompact difficulty target
targetstringFull proof-of-work target
difficultynumericDifficulty as a multiple of the minimum
chainworkstringCumulative work up to this block
nTxnumericNumber of transactions in the block
previousblockhashstringHash of the preceding block
nextblockhashstringHash of the following block, when one exists
strippedsizenumericBlock size excluding witness data
sizenumericBlock size in bytes
weightnumericBlock weight
txarrayFully decoded transactions, each in the same shape as rest/tx

Responses are large. This block is 1.59 MB serialized and decodes to a far bigger JSON document, and a request for it transfers the whole thing. For most work rest/block/notxdetails is the better call, followed by rest/tx for the transactions you actually want.

As with rest/tx, values are in BTC as decimals and no per-transaction fee is included.

Use Cases

  • Full Block Analysis: Read every transaction in a block in one request
  • Indexing: Build a local index from decoded block contents
  • Raw Retrieval: Fetch the serialized block with the .hex or .bin form

Error Handling

HTTP StatusMessageDescription
400Bad requestThe path is malformed, or a hash or height is invalid
403ForbiddenMissing or invalid ACCESS-TOKEN
404Not foundNo object matches the requested hash, height, or outpoint
500Internal errorThe node failed to process the request