net_peerCount — Ethereum JSON-RPC

Status: Available

Returns the number of peers currently connected to the Ethereum node, encoded as a hexadecimal integer.

POSThttps://triport.io/eth
Network
Ethereum
Auth
x-token: $TRIPORT_API_KEY (or Authorization: Bearer)
Rate limit
free — 10 RPS sustained · up to 20 burst · basic 20 · pro 100 · business 250; Burst capacity

Endpoint and plans: Ethereum RPC endpoint.

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. Send an empty params array.

——optional
None. params must be [].

Response

Response fields

FieldTypeDescription
resultstringNumber of connected peers as a hex-encoded integer (e.g. "0x2a" = 42).

Errors

CodeMeaningWhen it happens
401trial_expiredThe API key's trial period has ended; upgrade to a paid tier to continue.
429rate_limitedYou exceeded the requests-per-second limit for your tier (free 10 · basic 20 · pro 100 · business 250 RPS sustained · up to 500 burst). Retry after backing off.

Errors follow the standard JSON-RPC error envelope. See Errors for the full structure and shared error codes.

Examples

JavaScript (fetch)

const res = await fetch("https://triport.io/eth", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.TRIPORT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    jsonrpc: "2.0",
    id: 1,
    method: "net_peerCount",
    params: [],
  }),
});


const { result } = await res.json();
const peers = parseInt(result, 16);
console.log(`Connected peers: ${peers}`);

Notes

  • The result is hex-encoded — convert with parseInt(value, 16) (JS/TS) or int(value, 16) (Python) before using it numerically.
  • A result of "0x0" means the node currently has no connected peers, which usually indicates it is still discovering peers or is unhealthy.
  • Available on the Free trial; no scope required.
  • Related: net_listening, net_version, eth_syncing.