getBlockHeaderBranches

Retrieve Block Header Branches for a Specific Blockchain Chain

Overview

The /chain/{chain}/header/branch endpoint allows retrieval of a page of block headers from branches of the blockchain in descending order. It provides headers that are ancestors of any block in the set of upper bounds and are not ancestors of any block in the set of lower bounds.

Parameters

NameTypeRequiredDescription
apiVersionstringYesVersion of Kadena API "0.0"
nodeVersionenumYes"test-singleton" "development" "mainnet01" "testnet04"
chainstringYesThe specific chain ID from which to retrieve block hashes.
limitnumberNoThe maximum number of block headers to return.
nextstringNoA cursor for pagination to fetch subsequent block headers.
minheightnumberNoThe minimum block height to include in the results.
maxheightnumberNoThe maximum block height to include in the results.

Request Body

FieldTypeDescription
lowerarrayAn array of block hashes. No blocks are returned that are predecessors of any block with a hash from this array.
upperarrayAn array of block hashes. Returned block headers are predecessors of a block with a hash from this array. This includes blocks with hashes from this array.

Returns

A successful call to this endpoint returns a JSON object containing the following fields:

FieldDescription
nextThe cursor for the next page of block headers.
itemsAn array of block headers, detailing the branches in the blockchain.
limitThe maximum number of block headers returned in this response.

Request Example

curl --location 'https://api.tatum.io/v3/blockchain/node/kadena-mainnet/{api_key}/chainweb/{apiVersion}/{nodeVersion}/chain/{chain}/header/branch' \
--header 'Content-Type: application/json' \
--data-raw '{
    "lower": ["example_lower_hash"],
    "upper": ["example_upper_hash"]
}'
// yarn add @tatumio/tatum

import { TatumSDK, Blockchain } from "@tatumio/tatum";

const sdk = await TatumSDK.init<Blockchain>({ network: Network.BLOCKCHAIN_MAINNET });

const headerBranches = await sdk.rpc.getBlockHeaderBranches({
  chain: 0,
  lower: ["example_lower_hash"],
  upper: ["example_upper_hash"]
});

console.log(headerBranches);

await sdk.destroy(); // Destroy Tatum SDK - needed for stopping background jobs