For the complete documentation index, see llms.txt. This page is also available as Markdown.

getpeerinfo - Zcash

Example code for the getpeerinfo JSON-RPC method. Сomplete guide on how to use the getpeerinfo JSON-RPC method in GetBlock.io Web3 documentation.

This method returns detailed information about each connected peer. Post-Zebra 3.0.0, the response was extended with subver, version, services, lastrecv, banscore, and connection_state fields — bringing parity with Bitcoin Core's peer info surface and enabling detailed network diagnostics.

Parameters

This method takes no parameters.

Request

curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "getpeerinfo",
    "params": [],
    "id": "getblock.io"
}'
example.js
const axios = require('axios');

const response = await axios.post('https://go.getblock.io/<ACCESS-TOKEN>/', {
    jsonrpc: '2.0',
    method: 'getpeerinfo',
    params: [],
    id: 'getblock.io'
}, {
    headers: { 'Content-Type': 'application/json' }
});

console.log(response.data.result);
example.py
import requests

response = requests.post(
    'https://go.getblock.io/<ACCESS-TOKEN>/',
    headers={'Content-Type': 'application/json'},
    json={
        'jsonrpc': '2.0',
        'method': 'getpeerinfo',
        'params': [],
        'id': 'getblock.io'
    }
)

print(response.json())

Response

{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": [
        {
            "addr": "213.136.68.237:8233",
            "services": "0000000000000001",
            "lastrecv": 1784671886,
            "inbound": false,
            "banscore": 0,
            "subver": "/Zebra:5.1.0/",
            "version": 170150,
            "connection_state": "connected",
            "pingtime": 0.031849273
        },
         {
            "addr": "47.75.194.174:8233",
            "services": "0000000000000001",
            "lastrecv": 1784671855,
            "inbound": false,
            "banscore": 0,
            "subver": "/Zakura:1.0.1/",
            "version": 170160,
            "connection_state": "connected",
            "pingtime": 0.183128632
        }
    ]
}

Response Parameters

Parameter
Type
Description

id

integer

Peer identifier (per-node local ID)

addr

string

IP and port of the peer

addrbind

string

Local bind address for this connection

addrlocal

string

Local address as seen by the peer

services

string

Hex-encoded service bitmask (Zebra 3.0.0+)

lastsend

integer

Unix timestamp of the last message sent

lastrecv

integer

Unix timestamp of the last message received (Zebra 3.0.0+)

bytessent

integer

Total bytes sent to this peer

bytesrecv

integer

Total bytes received from this peer

conntime

integer

Unix timestamp of connection establishment

pingtime

number

Round-trip ping time in seconds

version

integer

Peer's protocol version (Zebra 3.0.0+)

subver

string

Peer's user agent string (Zebra 3.0.0+)

inbound

boolean

Whether this is an inbound connection

startingheight

integer

Peer's advertised starting height

banscore

integer

Misbehavior score (Zebra 3.0.0+)

synced_headers

integer

Last header height synced with this peer

synced_blocks

integer

Last block height synced with this peer

connection_state

string

Connection state (Ready, Handshake, etc.) (Zebra 3.0.0+)

Use Cases

  • Peer Health Diagnostics: Detect stalled peers via lastrecv gaps and elevated pingtime

  • Client Diversity Monitoring: Track subver distribution to measure network client diversity

  • Ban Score Alerts: Alert on peers approaching the ban threshold (typically 100)

  • Connection State Debugging: Use connection_state to diagnose handshake failures

Error Handling

Error Code
Message
Description

-32603

Internal error

Node failed to enumerate peer state

Last updated

Was this helpful?