# getRecentPerformanceSamples

The `getRecentPerformanceSamples` RPC method delivers a time‑series snapshot of Solana’s network performance, sampling roughly every 60 seconds. Each sample records the number of transactions processed and slots produced during that interval—critical metrics for assessing throughput and network health.

***

**Key Use Cases**

* **Network Health Monitoring**\
  Track transaction rates and slot production over time to detect congestion or slowdowns.
* **Performance Analysis**\
  Examine historical samples to identify trends, peak load periods, and capacity limits.
* **Dashboarding & Alerts**\
  Display TPS (transactions per second) and slots‑per‑minute on monitoring dashboards or trigger alerts when performance dips.
* **Capacity Planning**\
  Use sampled data to forecast resource needs for application scaling and infrastructure provisioning.

***

**Request Parameters**

* `limit` *(optional, usize)*:\
  Number of most recent samples to return (max 720, \~12 hours of data). Omitting `limit` returns the provider’s default sample count.

***

**Response Structure**

An array of performance sample objects in **reverse chronological** order:

| Field                    | Type | Description                                          |
| ------------------------ | ---- | ---------------------------------------------------- |
| `slot`                   | u64  | Slot at which this sample was recorded               |
| `numTransactions`        | u64  | Total transactions (including votes) in the period   |
| `numSlots`               | u64  | Slots produced during the sample interval            |
| `samplePeriodSecs`       | u16  | Actual duration of the sample (usually \~60 seconds) |
| `numNonVoteTransactions` | u64  | Transactions excluding consensus votes               |

***

#### Get the Last 5 Performance Samples <a href="#id-1-get-the-last-5-performance-samples" id="id-1-get-the-last-5-performance-samples"></a>

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

#### Get Default Number of Performance Samples <a href="#id-2-get-default-number-of-performance-samples" id="id-2-get-default-number-of-performance-samples"></a>

```json
{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getRecentPerformanceSamples"
}
```

***

**Code Examples**

{% tabs %}
{% tab title="Nodejs" %}

```javascript
const fetch = require('node-fetch');

async function getRecentPerformanceSamples(rpcUrl) {
  try {
    const response = await fetch(rpcUrl, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        jsonrpc: '2.0',
        id: 1,
        method: 'getRecentPerformanceSamples'
      }),
    });

    const data = await response.json();
    
    // Print the exact full response
    console.log('Full RPC Response:');
    console.log(JSON.stringify(data, null, 2));
    
    return data;
  } catch (error) {
    console.error('Error getting health:', error.message);
    return null;
  }
}

// Example usage
const RPC_URL = 'https://rpc.coinvera.io/?x-api-key=your-coinvera-x-api-key';

getRecentPerformanceSamples(RPC_URL);
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

def get_recent_performance_samples(rpc_url):
    try:
        response = requests.post(
            rpc_url,
            headers={
                'Content-Type': 'application/json',
            },
            json={
                'jsonrpc': '2.0',
                'id': 1,
                'method': 'getRecentPerformanceSamples'
            }
        )
        
        data = response.json()
        
        # Print the exact full response
        print('Full RPC Response:')
        print(json.dumps(data, indent=2))
        
        return data
        
    except Exception as error:
        print(f'Error getting health: {error}')
        return None

# Example usage
RPC_URL = 'https://rpc.coinvera.io/?x-api-key=your-coinvera-x-api-key'
get_recent_performance_samples(RPC_URL)
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "jsonrpc": "2.0",
  "result": [
    {
      "slot": 348125,
      "numTransactions": 126,
      "numSlots": 126,
      "samplePeriodSecs": 60,
      "numNonVoteTransactions": 1
    },
    {
      "slot": 347999,
      "numTransactions": 126,
      "numSlots": 126,
      "samplePeriodSecs": 60,
      "numNonVoteTransactions": 1
    }
  ],
  "id": 1
}
```

***

**Developer Tips**

* **Interval Variance**: Samples aim for \~60‑second intervals; check `samplePeriodSecs` to see the exact duration.
* **Data Retention**: Up to 720 samples (\~12 hours). For longer-term analysis, combine with external logging.
* **Vote vs. User Activity**: Use `numNonVoteTransactions` to focus on user‑driven load apart from voting traffic.
* **Node Differences**: Slight variations may occur between RPC nodes based on synchronization and local timing.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.coinvera.io/integration/solana/rpc/getrecentperformancesamples.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
