net_peerCount - Celo

This method returns the number of peers currently connected to the Celo node. This is useful for monitoring network connectivity.

Parameters

  • None

Request Example

curl

bashcurl -X POST https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/ \
-H "Content-Type: application/json" \
-d '{
  "jsonrpc": "2.0",
  "id": "getblock.io",
  "method": "net_peerCount",
  "params": []
}'

index.js

javascriptconst axios = require('axios');

const url = 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/';

const payload = {
  jsonrpc: '2.0',
  id: 'getblock.io',
  method: 'net_peerCount',
  params: []
};

axios.post(url, payload, {
  headers: { 'Content-Type': 'application/json' }
})
.then(response => console.log(response.data))
.catch(error => console.error(error));

example.py

pythonimport requests
import json

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

payload = {
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "method": "net_peerCount",
    "params": []
}

response = requests.post(url, headers={"Content-Type": "application/json"}, json=payload)
print(response.json())

Response Example

response.json

json{
  "jsonrpc": "2.0",
  "id": "getblock.io",
  "result": "0x19"
}

Response Definition

FieldTypeDescription
resultstringNumber of connected peers (hex)

Use Cases

  • Monitor network connectivity
  • Assess node health
  • Debug connection issues

Error Handling

Error CodeDescription
-32603Internal error