> ## Documentation Index
> Fetch the complete documentation index at: https://developers.avacloud.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Get staking metrics for a given subnet

> Gets staking metrics for a given subnet.



## OpenAPI

````yaml get /v2/networks/{network}/metrics/{metric}
openapi: 3.1.0
info:
  title: Metrics API
  description: >-
    The Metrics API provides metrics and analytics of on-chain activity. The API
    is in Beta and may be subject to change.</br></br>If you have feedback or
    feature requests for the API, please submit them <a
    href="https://portal.productboard.com/dndv9ahlkdfye4opdm8ksafi/tabs/4-glacier-api">here</a>.
    Bug reports can be submitted <a
    href="https://docs.google.com/forms/d/e/1FAIpQLSeJQrcp7QoNiqozMDKrVJGX5wpU827d3cVTgF8qa7t_J1Pb-g/viewform">here</a>,
    and any potential security issues can be reported <a
    href="https://hackenproof.com/avalanche">here</a>.
  version: 1.0.0
  contact: {}
servers:
  - url: https://metrics.avax.network
security: []
tags:
  - name: EVM Chains
    description: Find information about which routes are supported for a given EVM chainID.
  - name: Chain Metrics
    description: Get network level staking and usage metrics.
  - name: L1 Validator Metrics
    description: Get network level l1 validator metrics.
  - name: Looking Glass
    description: >-
      Looking Glass is a tool that allows users to look up information for
      future airdrops.
  - name: Health Check
  - name: Chain Throughput
    description: Get throughput metrics for a given chain.
  - name: Cumulative
    description: Get cumulative metrics for a given chain.
  - name: Staking Information
    description: Get staking information for a given chain.
paths:
  /v2/networks/{network}/metrics/{metric}:
    get:
      tags:
        - Chain Metrics
      summary: Get staking metrics for a given subnet
      description: Gets staking metrics for a given subnet.
      operationId: getStakingMetrics
      parameters:
        - name: metric
          required: true
          in: path
          description: Which network level metric to fetch.
          example: validatorCount
          schema:
            $ref: '#/components/schemas/NetworkMetric'
        - name: startTimestamp
          required: false
          in: query
          description: Query param for retrieving items after a specific timestamp.
          example: 1689541049
          schema:
            minimum: 0
            type: integer
        - name: endTimestamp
          required: false
          in: query
          description: Query param for retrieving items before a specific timestamp.
          example: 1689800249
          schema:
            minimum: 0
            type: integer
        - name: pageToken
          required: false
          in: query
          description: >-
            A page token, received from a previous list call. Provide this to
            retrieve the subsequent page.
          schema:
            type: string
        - name: pageSize
          required: false
          in: query
          description: >-
            The maximum number of items to return. The minimum page size is 1.
            The maximum pageSize is 2160.
          schema:
            type: integer
            default: 100
            minimum: 1
            maximum: 2160
          example: '10'
        - name: network
          required: true
          in: path
          description: Either mainnet or testnet/fuji.
          example: mainnet
          schema:
            $ref: '#/components/schemas/Network'
        - name: subnetId
          required: false
          in: query
          description: >-
            The subnet ID to filter by. If not provided, then all subnets will
            be returned.
          example: 11111111111111111111111111111111LpoYY
          schema:
            default: 11111111111111111111111111111111LpoYY
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MetricsApiResponse'
        '400':
          description: |-
            Bad requests generally mean the client has passed invalid 
                or malformed parameters. Error messages in the response could help in 
                evaluating the error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequest'
        '401':
          description: |-
            When a client attempts to access resources that require 
                authorization credentials but the client lacks proper authentication 
                in the request, the server responds with 401.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Unauthorized'
        '403':
          description: |-
            When a client attempts to access resources with valid
                credentials but doesn't have the privilege to perform that action, 
                the server responds with 403.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Forbidden'
        '404':
          description: |-
            The error is mostly returned when the client requests
                with either mistyped URL, or the passed resource is moved or deleted, 
                or the resource doesn't exist.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFound'
        '429':
          description: |-
            This error is returned when the client has sent too many,
                and has hit the rate limit.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TooManyRequests'
        '500':
          description: |-
            The error is a generic server side error that is 
                returned for any uncaught and unexpected issues on the server side. 
                This should be very rare, and you may reach out to us if the problem 
                persists for a longer duration.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalServerError'
        '502':
          description: |-
            This is an internal error indicating invalid response 
                  received by the client-facing proxy or gateway from the upstream server.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadGateway'
        '503':
          description: |-
            The error is returned for certain routes on a particular
                Subnet. This indicates an internal problem with our Subnet node, and may 
                not necessarily mean the Subnet is down or affected.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServiceUnavailable'
      x-codeSamples:
        - lang: javascript
          label: JavaScript
          source: |-
            import { Avalanche } from "@avalanche-sdk/chainkit";

            const avalanche = new Avalanche({
              network: "mainnet",
            });

            async function run() {
              const result = await avalanche.metrics.networks.getStakingMetrics({
                metric: "validatorCount",
                startTimestamp: 1689541049,
                endTimestamp: 1689800249,
                pageSize: 10,
              });

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

            run();
components:
  schemas:
    NetworkMetric:
      type: string
      enum:
        - delegatorCount
        - delegatorWeight
        - validatorCount
        - validatorWeight
    Network:
      type: string
      enum:
        - mainnet
        - fuji
        - testnet
    MetricsApiResponse:
      type: object
      properties:
        nextPageToken:
          type: string
          description: >-
            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.
        results:
          description: Array of current metrics values at different timestamps.
          type: array
          items:
            $ref: '#/components/schemas/MetricsValue'
      required:
        - results
    BadRequest:
      type: object
      properties:
        message:
          description: The error message describing the reason for the exception
          oneOf:
            - type: string
            - type: array
              items:
                type: string
        statusCode:
          type: number
          description: The HTTP status code of the response
          examples:
            - 400
        error:
          type: string
          description: The type of error
          examples:
            - Bad Request
      required:
        - message
        - statusCode
        - error
    Unauthorized:
      type: object
      properties:
        message:
          description: The error message describing the reason for the exception
          oneOf:
            - type: string
            - type: array
              items:
                type: string
        statusCode:
          type: number
          description: The HTTP status code of the response
          examples:
            - 401
        error:
          type: string
          description: The type of error
          examples:
            - Unauthorized
      required:
        - message
        - statusCode
        - error
    Forbidden:
      type: object
      properties:
        message:
          description: The error message describing the reason for the exception
          oneOf:
            - type: string
            - type: array
              items:
                type: string
        statusCode:
          type: number
          description: The HTTP status code of the response
          examples:
            - 403
        error:
          type: string
          description: The type of error
          examples:
            - Forbidden
      required:
        - message
        - statusCode
        - error
    NotFound:
      type: object
      properties:
        message:
          description: The error message describing the reason for the exception
          oneOf:
            - type: string
            - type: array
              items:
                type: string
        statusCode:
          type: number
          description: The HTTP status code of the response
          examples:
            - 404
        error:
          type: string
          description: The type of error
          examples:
            - Not Found
      required:
        - message
        - statusCode
        - error
    TooManyRequests:
      type: object
      properties:
        message:
          description: The error message describing the reason for the exception
          oneOf:
            - type: string
            - type: array
              items:
                type: string
        statusCode:
          type: number
          description: The HTTP status code of the response
          examples:
            - 429
        error:
          type: string
          description: The type of error
          examples:
            - Too Many Requests
      required:
        - message
        - statusCode
        - error
    InternalServerError:
      type: object
      properties:
        message:
          description: The error message describing the reason for the exception
          oneOf:
            - type: string
            - type: array
              items:
                type: string
        statusCode:
          type: number
          description: The HTTP status code of the response
          examples:
            - 500
        error:
          type: string
          description: The type of error
          examples:
            - Internal Server Error
      required:
        - message
        - statusCode
        - error
    BadGateway:
      type: object
      properties:
        message:
          description: The error message describing the reason for the exception
          oneOf:
            - type: string
            - type: array
              items:
                type: string
        statusCode:
          type: number
          description: The HTTP status code of the response
          examples:
            - 502
        error:
          type: string
          description: The type of error
          examples:
            - Bad Gateway
      required:
        - message
        - statusCode
        - error
    ServiceUnavailable:
      type: object
      properties:
        message:
          description: The error message describing the reason for the exception
          oneOf:
            - type: string
            - type: array
              items:
                type: string
        statusCode:
          type: number
          description: The HTTP status code of the response
          examples:
            - 503
        error:
          type: string
          description: The type of error
          examples:
            - Service Unavailable
      required:
        - message
        - statusCode
        - error
    MetricsValue:
      type: object
      properties:
        value:
          type: number
          description: Aggregated value for the current metrics.
        timestamp:
          type: number
          description: >-
            Unix Epoch timestamp for which metrics are aggregated. Depending on
            the interval of the metric this can be at the start of the relevant
            hour, day, month, year, etc.
      required:
        - value
        - timestamp

````