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 (is the node accepting connections) and
net_version (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
| Field | Type |
|---|---|
| result | object |
Examples
curl https://triport.io/sol \
-X POST -H 'Content-Type: application/json' \
-H 'Authorization: Bearer <api-key>' \
-d '{"id":1,"method":"net_peerCount","params":[],"jsonrpc":"2.0"}'const res = await fetch("https://triport.io/sol", {
method: "POST",
headers: { "Content-Type": "application/json", Authorization: "Bearer <api-key>" },
body: JSON.stringify({
"id": 1,
"method": "net_peerCount",
"params": [],
"jsonrpc": "2.0"
}),
});
const data = await res.json();import requests
resp = requests.post(
"https://triport.io/sol",
headers={"Authorization": "Bearer <api-key>"},
json={"id":1,"method":"net_peerCount","params":[],"jsonrpc":"2.0"},
)
print(resp.json())Usage
- Transport: HTTP (JSON-RPC).
- Networks: mainnet.
- 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.