Making Requests
You can interact with the Metrics API by sending HTTP GET requests to the provided endpoints. Below is an example of a simplecurl request.
chainId with the specific chain ID you want to query. For example, to retrieve the average transactions per second (TPS) for a specific chain (in this case, chain ID 43114), you can use the following endpoint:
lastRun is a timestamp indicating when the last data point was updated:
Rate Limits
Even though the Metrics API does not require authentication, it still enforces rate limits to ensure stability and performance. If you exceed these limits, the server will respond with a 429 Too Many Requests HTTP response code.Error Types
The API generates standard error responses along with error codes based on provided requests and parameters. Typically, response codes within the2XX range signifies successful requests, while those within the 4XX range points to errors originating from the client’s side. Meanwhile, response codes within the 5XX range indicates problems on the server’s side.
The error response body is formatted like this:
Pagination
For endpoints that return large datasets, the Metrics API employs pagination to manage the results. When querying for lists of data, you may receive a nextPageToken in the response, which can be used to request the next page of data. Example response with pagination:Pagination Details
Page Token Structure
ThenextPageToken is a UUID-based token provided in the response when additional pages of data are available. This token serves as a pointer to the next set of data.
- UUID Generation: The
nextPageTokenis generated uniquely for each pagination scenario, ensuring security and ensuring predictability. - Expiration: The token is valid for 24 hours from the time it is generated. After this period, the token will expire, and a new request starting from the initial page will be required.
- Presence: The token is only included in the response when there is additional data available. If no more data exists, the token will not be present.
Integration and Usage
To use the pagination system effectively:- Check if the
nextPageTokenis present in the response. - If present, include this token in the subsequent request to fetch the next page of results.
- Ensure that the follow-up request is made within the 24-hour window after the token was generated to avoid token expiration.