monitor-heads - Tezos
Example code for the /monitor/heads/main REST method. Complete guide on how to use the /monitor/heads/main REST method in GetBlock Web3 documentation
Opens a streaming response that emits each new block header as it is appended to the main chain. Use it to react to new blocks in real time. This is a long-lived monitor endpoint.
Endpoint
GET /monitor/heads/mainExample
export TEZOS_REST=https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/
curl "${TEZOS_REST}monitor/heads/main"const axios = require('axios');
const response = await axios.get('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/monitor/heads/main', {
headers: { 'Content-Type': 'application/json' },
responseType: 'stream'
});
response.data.on('data', chunk => {
console.log(chunk.toString());
});import requests
response = requests.get(
'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/monitor/heads/main',
headers={'Content-Type': 'application/json'},
stream=True
)
for line in response.iter_lines():
if line:
print(line.decode())Response
{
"hash": "BMblockhash...",
"level": 5000000,
"proto": 20,
"predecessor": "BMprev...",
"timestamp": "2025-01-15T12:00:00Z",
"operations_hash": "LLoa...",
"fitness": [
"02",
"..."
]
}Response Fields
(stream)
object
One block header object per new head
Use Cases
Real-Time Feeds: Trigger logic on every new block
Confirmation Watching: Detect when a transaction's block is produced
Error Handling
400 / Bad request
Bad request
A path or body parameter was invalid
404 / Not found
Not found
The block, contract, or resource does not exist
403 / RBAC: access denied
Access denied
The GetBlock access token is missing or incorrect
Was this helpful?