rest/blockhashbyheight - Bitcoin

This endpoint returns the hash of the block at a given height on the main chain.

Parameters

ParameterTypeLocationRequiredDescription
heightintegerpathYesBlock height on the main chain
formatstringpathYesResponse format appended to the height: json, hex, or bin

Request

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

example.js

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

example.py

pythonimport requests

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

print(response.json())

Response

json{
    "blockhash": "000000000000000000019c481c042c0625abe1dc04fe26795e2e24b152791e5f"
}

Response Parameters

FieldTypeDescription
blockhashstringHash of the block at the requested height

Every other REST path takes a block hash, so this is usually the first call when you only know a height.

Use Cases

  • Height to Hash: Resolve a height before calling an endpoint that takes a hash
  • Chain Checks: Confirm which block occupies a height after a reorganization
  • Indexing: Walk heights sequentially while building a local index

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