---
title: "net_peerCount"
description: "Returns the number of peers currently connected to the client (Avalanche)"
url: "https://blockreq.com/docs/build/api-reference/avalanche/net_peerCount/"
---

# net_peerCount

**Network:** Avalanche · Mainnet · Chain ID `43114` (`0xa86a`)

**Counts as 1 request.** See [Request Counting](https://blockreq.com/docs/pricing/request-counting/index.md).

## Description

Returns the number of peers currently connected to the client.

## Parameters

None

## Request

```json
{
  "jsonrpc": "2.0",
  "method": "net_peerCount",
  "params": [],
  "id": 1
}
```

## Code Examples

**cURL**

```bash
curl -X POST https://avalanche-rpc.blockreq.com/v1/rpc/public \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":1}'
```

**TypeScript**

```typescript
const response = await fetch("https://avalanche-rpc.blockreq.com/v1/rpc/public", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
  "jsonrpc": "2.0",
  "method": "net_peerCount",
  "params": [],
  "id": 1
}),
});
const data = await response.json();
console.log(data.result);
```

**Python**

```python
import requests

response = requests.post(
    "https://avalanche-rpc.blockreq.com/v1/rpc/public",
    json={
  "jsonrpc": "2.0",
  "method": "net_peerCount",
  "params": [],
  "id": 1
}
)
print(response.json()["result"])
```

**Go**

```go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"net/http"
)

func main() {
	payload := []byte(`{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":1}`)
	resp, err := http.Post(
		"https://avalanche-rpc.blockreq.com/v1/rpc/public",
		"application/json",
		bytes.NewBuffer(payload),
	)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	body, _ := io.ReadAll(resp.Body)
	var result map[string]interface{}
	json.Unmarshal(body, &result)
	fmt.Println(result["result"])
}
```

**viem**

```typescript
import { createPublicClient, http } from "viem";

const client = createPublicClient({
  transport: http("https://avalanche-rpc.blockreq.com/v1/rpc/public"),
});

const result = await client.request({
  method: "net_peerCount",
  params: [],
});
console.log(result);
```

**Foundry**

```bash
cast rpc --rpc-url https://avalanche-rpc.blockreq.com/v1/rpc/public net_peerCount
```

**Hardhat**

```javascript
const { ethers } = require("hardhat");

async function main() {
  const provider = new ethers.JsonRpcProvider("https://avalanche-rpc.blockreq.com/v1/rpc/public");
  const result = await provider.send("net_peerCount", []);
  console.log(result);
}

main();
```
