TriportRPC

net_peerCount

Last updated:

`net_peerCount` reports how many peers the node serving your request is currently connected to on the Ethereum peer-to-peer network. The count is returned as a hex-encoded integer string (e.g. `"0x2a"` for 42 peers).

Use it as a lightweight liveness/health signal — a healthy node maintains a stable, non-zero peer count. It pairs naturally with [`net_listening`](./net_listening.md) (is the node accepting connections) and [`net_version`](./net_version.md) (which network the node is on).

The value reflects the state of the node that handled the request at that moment; because requests may be served by different backends, treat the number as an instantaneous reading rather than a fixed property of your endpoint.

Parameters

This method takes no parameters.

Returns

net_peerCount return value
FieldType
resultobject

Examples

curl https://<your-endpoint>/ \
  -X POST -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"net_peerCount","params":[]}'
const res = await fetch("https://<your-endpoint>/", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
  "id": 1,
  "method": "net_peerCount",
  "params": [],
  "jsonrpc": "2.0"
}),
});
const data = await res.json();
import requests
resp = requests.post("https://<your-endpoint>/", json={"id":1,"method":"net_peerCount","params":[],"jsonrpc":"2.0"})
print(resp.json())

Usage

  1. Transport: HTTP (JSON-RPC).
  2. Networks: mainnet.
  3. Credit cost: 1 per call.

FAQ

What does net_peerCount do?
Returns the number of peers currently connected to the Ethereum node, encoded as a hexadecimal integer.
How many credits does net_peerCount cost?
net_peerCount costs 1 credit(s) per call on Triport by default.
Is net_peerCount available over WebSocket?
net_peerCount is an HTTP JSON-RPC method.