net_peerCount
https://api.triport.io/v1/polygonReturns the number of peers currently connected to the node's p2p network, as a hexadecimal string.
net_peerCount reports how many p2p peers the underlying Polygon node is
connected to, encoded as a hex-quantity string (e.g. "0x2a" → 42). It is part
of the standard net_* network-info namespace and takes no parameters.
Use it as a lightweight node-health / connectivity signal. The value is most
meaningful on the Bor-consensus backends that serve Polygon mainnet
(chainId 0x89 / 137), where it reflects the node's real Bor p2p peer count.
Gotcha — value reliability: behind some load-balanced / CDN-fronted
infrastructure the peer count is not a real metric. Such backends may return a
fabricated constant or "0x0" regardless of the actual peer topology. Treat a
zero or suspiciously static value as "unknown" rather than "no peers", and do
not build alerting on the absolute number unless you have confirmed your route
serves a direct Bor backend. The count is a coarse signal, not a precise gauge.
Parameters
This method takes no parameters. Send an empty params array.
——optionalparams must be [].Response
Response fields
| Field | Type | Description |
|---|---|---|
jsonrpc | string | Always "2.0". |
id | number | Echoes the request id. |
result | string | Number of connected p2p peers as a hex-quantity string (e.g. "0x2a" = 42). Parse with parseInt(result, 16). |
Errors
Errors are returned in the standard JSON-RPC error envelope. See the shared errors reference for the full envelope shape and handling guidance.
| Code | Meaning | When it happens |
|---|---|---|
-32601 | Method not found | The method name is misspelled or not enabled on the route. |
-32001 | Auth / key error | Missing, invalid, or revoked TRIPORT_API_KEY. |
-32002 | Insufficient tier / scope | Key lacks the polygon_read_rpc capability. |
-32003 | Rate limit exceeded | Per-tier RPS (incl. burst) was exceeded — back off and retry. |
-32004 | Upstream unavailable | No healthy backend could serve the request. |
-32005 | Upstream timeout | The backend did not respond in time. |
Examples
JavaScript (fetch)
const res = await fetch("https://api.triport.io/v1/polygon", {
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}`);TypeScript SDK (@triport/sdk)
import { TriportClient } from "@triport/sdk";
const client = new TriportClient({ apiKey: process.env.TRIPORT_API_KEY! });
const result = await client.polygon.rpc<string>("net_peerCount");
const peers = parseInt(result, 16);
console.log(`connected peers: ${peers}`);Python (triport-sdk)
import os
from triport import TriportClient
client = TriportClient(api_key=os.environ["TRIPORT_API_KEY"])
result = client.polygon.rpc("net_peerCount")
peers = int(result, 16)
print(f"connected peers: {peers}")Notes
- No parameters, no caching semantics on the client side — the value changes as peers connect and disconnect, so re-query when you need a fresh reading.
- This is a
net_*info method. Related:net_version(chain id as a decimal string) andnet_listening(whether the node is accepting p2p connections — practically alwaystrue). - For a richer node-identity signal, see
web3_clientVersion. - The peer count is best treated as a health hint. For block-level liveness,
prefer
eth_blockNumber.