getnetworkinfo - Zcash

This method returns network status information for the node, including its protocol version and connection count.

Zebra returns a subset of Bitcoin Core's getnetworkinfo. The per-direction counts connections_in and connections_out, and the localrelay, networkactive, and incrementalfee fields, are not present.

Parameters

This method takes no parameters.

Request

bashcurl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "getnetworkinfo",
    "params": [],
    "id": "getblock.io"
}'

example.js

javascriptconst axios = require('axios');

const response = await axios.post('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', {
    jsonrpc: '2.0',
    method: 'getnetworkinfo',
    params: [],
    id: 'getblock.io'
}, {
    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',
        'method': 'getnetworkinfo',
        'params': [],
        'id': 'getblock.io'
    }
)

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 response = client
        .post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
        .header("Content-Type", "application/json")
        .json(&json!({
            "jsonrpc": "2.0",
            "method": "getnetworkinfo",
            "params": [],
            "id": "getblock.io"
        }))
        .send()
        .await?
        .json::<Value>()
        .await?;
    
    println!("Result: {}", response["result"]);
    Ok(())
}

Response

json{
    "jsonrpc": "2.0",
    "result": {
        "version": 6030000,
        "subversion": "/Zebra:6.3.0/",
        "protocolversion": 170160,
        "localservices": "0000000000000001",
        "timeoffset": 0,
        "connections": 69,
        "networks": [
            {
                "name": "ipv4",
                "limited": false,
                "reachable": true,
                "proxy": "",
                "proxy_randomize_credentials": false
            },
            {
                "name": "ipv6",
                "limited": false,
                "reachable": true,
                "proxy": "",
                "proxy_randomize_credentials": false
            },
            {
                "name": "onion",
                "limited": false,
                "reachable": false,
                "proxy": "",
                "proxy_randomize_credentials": false
            }
        ],
        "relayfee": 1e-06,
        "localaddresses": [],
        "warnings": ""
    },
    "id": "getblock.io"
}

Response Parameters

ParameterTypeDescription
versionintegerZebra numeric version
subversionstringUser agent string sent to peers
protocolversionintegerP2P protocol version
localservicesstringHex-encoded services supported by this node
timeoffsetintegerMedian time offset in seconds vs peer clocks
connectionsintegerTotal active peer connections
networksarray of objectPer-network (IPv4, IPv6, Tor) status objects
relayfeenumberMinimum relay fee in ZEC/kB
localaddressesarray of objectLocally-advertised addresses
warningsstringAny node warnings (empty if none)

Use Cases

  • Health Checks: Read connections to confirm the node has peers
  • Version Checks: Read subversion and protocolversion to identify the node
  • Fee Floors: Read relayfee for the minimum relay fee in ZEC per kilobyte
  • Node Warnings Monitoring: Poll the warnings field to detect network-layer issues that don't stop the node

Error Handling

Error CodeMessageDescription
-32601Method not foundNode does not expose getnetworkinfo
-32603Internal errorNode failed to compile the network info payload