JavaScript
import { Avalanche } from "@avalanche-sdk/chainkit";
const avalanche = new Avalanche();
async function run() {
const result = await avalanche.data.evm.blocks.listLatestAllChains({
pageSize: 10,
network: "mainnet",
});
for await (const page of result) {
console.log(page);
}
}
run();curl --request GET \
--url https://glacier-api.avax.network/v1/blocks \
--header 'x-glacier-api-key: <api-key>'import requests
url = "https://glacier-api.avax.network/v1/blocks"
headers = {"x-glacier-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://glacier-api.avax.network/v1/blocks",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-glacier-api-key: <api-key>"
],
]);
$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://glacier-api.avax.network/v1/blocks"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-glacier-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://glacier-api.avax.network/v1/blocks")
.header("x-glacier-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://glacier-api.avax.network/v1/blocks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-glacier-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"blocks": [
{
"chainId": "<string>",
"blockNumber": "<string>",
"blockTimestamp": 123,
"blockHash": "<string>",
"txCount": 123,
"baseFee": "<string>",
"gasUsed": "<string>",
"gasLimit": "<string>",
"gasCost": "<string>",
"parentHash": "<string>",
"feesSpent": "<string>",
"cumulativeTransactions": "<string>"
}
],
"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>"
}Blocks
List latest blocks across all supported EVM chains
Lists the most recent blocks from all supported EVM-compatible chains. The results can be filtered by network.
GET
/
v1
/
blocks
JavaScript
import { Avalanche } from "@avalanche-sdk/chainkit";
const avalanche = new Avalanche();
async function run() {
const result = await avalanche.data.evm.blocks.listLatestAllChains({
pageSize: 10,
network: "mainnet",
});
for await (const page of result) {
console.log(page);
}
}
run();curl --request GET \
--url https://glacier-api.avax.network/v1/blocks \
--header 'x-glacier-api-key: <api-key>'import requests
url = "https://glacier-api.avax.network/v1/blocks"
headers = {"x-glacier-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://glacier-api.avax.network/v1/blocks",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-glacier-api-key: <api-key>"
],
]);
$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://glacier-api.avax.network/v1/blocks"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-glacier-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://glacier-api.avax.network/v1/blocks")
.header("x-glacier-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://glacier-api.avax.network/v1/blocks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-glacier-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"blocks": [
{
"chainId": "<string>",
"blockNumber": "<string>",
"blockTimestamp": 123,
"blockHash": "<string>",
"txCount": 123,
"baseFee": "<string>",
"gasUsed": "<string>",
"gasLimit": "<string>",
"gasCost": "<string>",
"parentHash": "<string>",
"feesSpent": "<string>",
"cumulativeTransactions": "<string>"
}
],
"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>"
}Authorizations
Api keys provide higher access to rate limits. To obtain an api key, sign up for an account at https://avacloud.io/.
Query Parameters
A page token, received from a previous list call. Provide this to retrieve the subsequent page.
The maximum number of items to return. The minimum page size is 1. The maximum pageSize is 100.
Required range:
1 <= x <= 100Either mainnet or testnet/fuji.
Available options:
mainnet, fuji, testnet Was this page helpful?
⌘I