block_search - Axelar

Returns blocks matching a block-event query (for example by begin/end-block events), paginated. Requires block indexing.

Parameters

ParameterTypeRequiredDescription
querystringYesBlock-event query
pagestringOptionalPage
per_pagestringOptionalResults per page
order_bystringOptionalasc or desc

Request

bashcurl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "method": "block_search",
    "params": {"query": "block.height > 19000000", "page": "1", "per_page": "20", "order_by": "desc"}
}'

example.js

javascriptconst axios = require('axios');
const response = await axios.post('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', { jsonrpc: '2.0', id: 'getblock.io', method: 'block_search', params: {"query": "block.height > 19000000", "page": "1", "per_page": "20", "order_by": "desc"} }, { headers: { 'Content-Type': 'application/json' } });
console.log(response.data.result);

example.py

pythonimport requests
response = requests.post('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', headers={'Content-Type': 'application/json'}, json={'jsonrpc': '2.0', 'id': 'getblock.io', 'method': 'block_search', 'params': {"query": "block.height > 19000000", "page": "1", "per_page": "20", "order_by": "desc"}})
print(response.json())

example.rs

rustuse reqwest::Client;
use serde_json::{json, Value};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();
    let res = client.post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/").json(&json!({"jsonrpc":"2.0","id":"getblock.io","method":"block_search","params":{"query": "block.height > 19000000", "page": "1", "per_page": "20", "order_by": "desc"}})).send().await?.json::<Value>().await?;
    println!("{}", res["result"]);
    Ok(())
}

Response

json{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": {
        "blocks": [
            {
                "block_id": {
                    "hash": "E1F2..."
                },
                "block": {
                    "header": {
                        "height": "19500000"
                    }
                }
            }
        ],
        "total_count": "1"
    }
}

Response Fields

FieldTypeDescription
blocksarrayMatching blocks
total_countstringTotal matches

Use Cases

  • Event Search: Find blocks by begin/end-block events
  • Indexing: Locate blocks by criteria

Error Handling

ErrorMessageDescription
-32603 / Internal errorInternal errorBlock indexing disabled or bad query
403 / RBAC: access deniedAccess deniedThe GetBlock access token is missing or incorrect