monitor-heads - Tezos

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

httpGET /monitor/heads/main

Example

bashexport TEZOS_REST=https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/

curl "${TEZOS_REST}monitor/heads/main"

example.js

javascriptconst 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());
});

example.py

pythonimport 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())

example.rs

rustuse reqwest::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();

    let mut response = client
        .get("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/monitor/heads/main")
        .header("Content-Type", "application/json")
        .send()
        .await?;

    while let Some(chunk) = response.chunk().await? {
        println!("{}", String::from_utf8_lossy(&chunk));
    }

    Ok(())
}

Response

json{
    "hash": "BMblockhash...",
    "level": 5000000,
    "proto": 20,
    "predecessor": "BMprev...",
    "timestamp": "2025-01-15T12:00:00Z",
    "operations_hash": "LLoa...",
    "fitness": [
        "02",
        "..."
    ]
}

Response Fields

FieldTypeDescription
(stream)objectOne 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

ErrorMessageDescription
400 / Bad requestBad requestA path or body parameter was invalid
404 / Not foundNot foundThe block, contract, or resource does not exist
403 / RBAC: access deniedAccess deniedThe GetBlock access token is missing or incorrect