Skip to main content
GET
/
v1
/
networks
/
{network}
/
blockchains
/
{blockchainId}
/
blocks
/
{blockId}
JavaScript
import { Avalanche } from "@avalanche-sdk/chainkit";

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

async function run() {
  const result = await avalanche.data.primaryNetwork.blocks.get({
    blockchainId: "p-chain",
    blockId: "5615di9ytxujackzaXNrVuWQy5y8Yrt8chPCscMr5Ku9YxJ1S",
  });

  console.log(result);
}

run();
curl --request GET \
--url https://glacier-api.avax.network/v1/networks/{network}/blockchains/{blockchainId}/blocks/{blockId} \
--header 'x-glacier-api-key: <api-key>'
import requests

url = "https://glacier-api.avax.network/v1/networks/{network}/blockchains/{blockchainId}/blocks/{blockId}"

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/networks/{network}/blockchains/{blockchainId}/blocks/{blockId}",
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/networks/{network}/blockchains/{blockchainId}/blocks/{blockId}"

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/networks/{network}/blockchains/{blockchainId}/blocks/{blockId}")
.header("x-glacier-api-key", "<api-key>")
.asString();
require 'uri'
require 'net/http'

url = URI("https://glacier-api.avax.network/v1/networks/{network}/blockchains/{blockchainId}/blocks/{blockId}")

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
{
  "blockNumber": "<string>",
  "blockHash": "<string>",
  "parentHash": "<string>",
  "blockTimestamp": 123,
  "blockType": "<string>",
  "txCount": 123,
  "transactions": [
    "<string>"
  ],
  "blockSizeBytes": 123,
  "l1ValidatorsAccruedFees": 123,
  "activeL1Validators": 123,
  "currentSupply": "<string>",
  "proposerDetails": {
    "proposerId": "<string>",
    "proposerParentId": "<string>",
    "proposerNodeId": "<string>",
    "proposerPChainHeight": 123,
    "proposerTimestamp": 123
  }
}
{
"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

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/.

Path Parameters

blockchainId
enum<string>
required

A primary network blockchain id or alias.

Available options:
11111111111111111111111111111111LpoYY,
2oYMBNV4eNHyqk2fjjV5nVQLDbtmNJzq5s3qs3Lo6ftnC6FByM,
2JVSBoinj9C2J33VntvzYtVJNZdN2NKiwwKjcumHUWEb5DbBrm,
2q9e4r6Mu3U68nU1fYjgbR6JvwrRx36CohpAX5UQxse55x1Q5,
yH8D7ThNJkxmtkuv2jgBa4P1Rn3Qpr4pPr7QYNfcdoS6k6HWp,
p-chain,
x-chain,
c-chain
network
enum<string>
required

Either mainnet or testnet/fuji.

Available options:
mainnet,
fuji,
testnet
blockId
string
required

A block identifier which is either a block number or the block hash.

Response

Successful response

blockNumber
string
required
blockHash
string
required
parentHash
string
required
blockTimestamp
number
required
blockType
string
required
txCount
number
required
transactions
string[]
required
blockSizeBytes
number
required
l1ValidatorsAccruedFees
number
activeL1Validators
number
currentSupply
string
proposerDetails
object