Skip to main content
GET
/
v2
/
chains
/
{chainId}
/
metrics
/
{metric}
JavaScript
import { Avalanche } from "@avalanche-sdk/chainkit";

const avalanche = new Avalanche({
  chainId: "43114",
});

async function run() {
  const result = await avalanche.metrics.chains.getMetrics({
    metric: "activeAddresses",
    startTimestamp: 1689541049,
    endTimestamp: 1689800249,
    timeInterval: "day",
    pageSize: 10,
  });

  for await (const page of result) {
    console.log(page);
  }
}

run();
curl --request GET \
--url https://metrics.avax.network/v2/chains/{chainId}/metrics/{metric}
import requests

url = "https://metrics.avax.network/v2/chains/{chainId}/metrics/{metric}"

response = requests.get(url)

print(response.text)
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://metrics.avax.network/v2/chains/{chainId}/metrics/{metric}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"net/http"
"io"
)

func main() {

url := "https://metrics.avax.network/v2/chains/{chainId}/metrics/{metric}"

req, _ := http.NewRequest("GET", url, nil)

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.get("https://metrics.avax.network/v2/chains/{chainId}/metrics/{metric}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://metrics.avax.network/v2/chains/{chainId}/metrics/{metric}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
{
  "results": [
    {
      "value": 123,
      "timestamp": 123
    }
  ],
  "nextPageToken": "<string>"
}
{
"message": "<string>",
"statusCode": 123,
"error": "<string>"
}
{
"message": "<string>",
"statusCode": 123,
"error": "<string>"
}
{
"message": "<string>",
"statusCode": 123,
"error": "<string>"
}
{
"message": "<string>",
"statusCode": 123,
"error": "<string>"
}
{
"message": "<string>",
"statusCode": 123,
"error": "<string>"
}
{
"message": "<string>",
"statusCode": 123,
"error": "<string>"
}
{
"message": "<string>",
"statusCode": 123,
"error": "<string>"
}
{
"message": "<string>",
"statusCode": 123,
"error": "<string>"
}

Path Parameters

metric
enum<string>
required

Which chain level metric to fetch.

Available options:
activeAddresses,
activeSenders,
cumulativeTxCount,
cumulativeAddresses,
cumulativeContracts,
cumulativeDeployers,
contracts,
deployers,
gasUsed,
txCount,
avgGps,
maxGps,
avgTps,
maxTps,
avgGasPrice,
maxGasPrice,
feesPaid
chainId
string
required

A supported EVM chain ID or one of "total", "mainnet", or "testnet". Use the /chains endpoint to get a list of supported chain IDs.

Query Parameters

startTimestamp
integer

Query param for retrieving items after a specific timestamp.

Required range: x >= 0
endTimestamp
integer

Query param for retrieving items before a specific timestamp.

Required range: x >= 0
timeInterval
enum<string>

Time interval granularity for data aggregation. Metrics prefixed with "cumulative", "max", or "avg" only support timeInterval equal to "day".

Available options:
hour,
day,
week,
month
pageToken
string

A page token, received from a previous list call. Provide this to retrieve the subsequent page.

pageSize
integer
default:100

The maximum number of items to return. The minimum page size is 1. The maximum pageSize is 2160.

Required range: 1 <= x <= 2160

Response

Successful response

results
object[]
required

Array of current metrics values at different timestamps.

nextPageToken
string

A token, which can be sent as pageToken to retrieve the next page. If this field is omitted or empty, there are no subsequent pages.