GET
/
v1
/
apiUsageMetrics
JavaScript
import { Avalanche } from "@avalanche-sdk/chainkit";

const avalanche = new Avalanche();

async function run() {
  const result = await avalanche.data.usageMetrics.getUsage({
    startTimestamp: 1739507200,
    endTimestamp: 1739664000,
    timeInterval: "daily",
    groupBy: "requestPath",
  });

  console.log(result);
}

run();
{
  "aggregateDuration": "<string>",
  "orgId": "<string>",
  "metrics": [
    {
      "timestamp": 123,
      "values": [
        {
          "groupedBy": "requestPath",
          "groupValue": "<string>",
          "totalRequests": 123,
          "requestsPerSecond": 123,
          "successRatePercent": 123,
          "medianResponseTimeMsecs": 123,
          "invalidRequests": 123,
          "apiCreditsUsed": 123,
          "apiCreditsWasted": 123
        }
      ]
    }
  ]
}

Authorizations

x-glacier-api-key
string
header
required

Api keys provide higher access to rate limits. To obtain an api key, sign up for an account at https://avacloud.io/.

Query Parameters

orgId
string

Organization ID to fetch usage metrics for

startTimestamp
integer

The start time of the range as a UNIX timestamp. The requested start time will be rounded down to 0:00 UTC of the day.

Required range: x >= 0
endTimestamp
integer

The end time of the range as a UNIX timestamp. The requested end time will be rounded down to 0:00 UTC of the day.

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

Time interval granularity for data aggregation

Available options:
minute,
hourly,
daily,
weekly,
monthly
groupBy
enum<string>

Query param for the criterion used for grouping metrics

Available options:
requestPath,
responseCode,
chainId,
apiKeyId,
requestType
chainId
string

Filter data by chain ID.

responseCode
string

Filter data by response status code.

requestType
enum<string>

Filter data by request type.

Available options:
data,
rpc
apiKeyId
string

Filter data by API key ID.

requestPath
string

Filter data by request path.

Response

Successful response

aggregateDuration
string
required

Duration in which the metrics value is aggregated

orgId
string
required

Org ID for which the metrics are aggregated

metrics
object[]
required

Metrics values