GET
/
v1
/
apiUsageMetrics
import { AvaCloudSDK } from "@avalabs/avacloud-sdk";

const avaCloudSDK = new AvaCloudSDK({
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const result = await avaCloudSDK.data.usageMetrics.getApiUsageMetrics({
    startTimestamp: 1698100000,
    endTimestamp: 1698300000,
    timeInterval: "daily",
    groupBy: "requestPath",
  });

  // Handle the result
  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

200
application/json
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