getBlockInfo Query
Parameters
This method does not accept any parameters
Returns
data
object
The data object which contains the following fields:
block
object
The object that holds information about the specific block
id
string
The unique identifier (hash) of the block
height
string
The height of the block
transactions
array
An array of transactions included in the block
id
string
The unique identifier (hash) of each transaction in the block.
Request
curl --location 'https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql' \ --header 'Accept: application/json' \ --header 'Content-Type: application/json' \ --data '{ "query": "query BlockById($id: BlockId!) { block(id: $id) { id height transactions { id } } }", "variables": { "id": "0x37f8a43bc7a5c0460bd7478a41f191a74dfb3685f00e48a316d8406658dc0dad" } }'
const BLOCK_QUERY = ` query { block(id: "0x37f8a43bc7a5c0460bd7478a41f191a74dfb3685f00e48a316d8406658dc0dad") { id height transactions { id } } } `; const fetchBlockInfo = async (): Promise<void> => { try { const response = await fetch('https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql', { method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', }, body: JSON.stringify({ query: BLOCK_QUERY, }), }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const result = await response.json(); console.log('Block ID:', result.data.block.id); console.log('Block Height:', result.data.block.height); console.log('Transactions:', result.data.block.transactions.map((tx: any) => tx.id)); } catch (error) { console.error('Error fetching block info:', error); } }; fetchBlockInfo();
const myHeaders = new Headers(); myHeaders.append("Accept", "application/json"); myHeaders.append("Content-Type", "application/json"); const raw = JSON.stringify({ "query": "query BlockById($id: BlockId!) { block(id: $id) { id height transactions { id } } }", "variables": { "id": "0x37f8a43bc7a5c0460bd7478a41f191a74dfb3685f00e48a316d8406658dc0dad" } }); const requestOptions = { method: "POST", headers: myHeaders, body: raw, redirect: "follow" }; fetch("https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql", requestOptions) .then((response) => response.text()) .then((result) => console.log(result)) .catch((error) => console.error(error));
const { ApolloClient, InMemoryCache, gql } = require('@apollo/client/core'); const fetch = require('cross-fetch'); const client = new ApolloClient({ uri: 'https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql', cache: new InMemoryCache(), fetch: fetch, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }); const BLOCK_BY_ID_QUERY = gql` query BlockById($id: BlockId!) { block(id: $id) { id height transactions { id } } } `; const variables = { id: "0x37f8a43bc7a5c0460bd7478a41f191a74dfb3685f00e48a316d8406658dc0dad" }; client.query({ query: BLOCK_BY_ID_QUERY, variables: variables }) .then(result => { console.log(JSON.stringify(result.data, null, 2)); }) .catch(error => console.error('Error:', error));
import requests import json url = "https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql" payload = json.dumps({ "query": "query BlockById($id: BlockId!) { block(id: $id) { id height transactions { id } } }", "variables": { "id": "0x37f8a43bc7a5c0460bd7478a41f191a74dfb3685f00e48a316d8406658dc0dad" } }) headers = { 'Accept': 'application/json', 'Content-Type': 'application/json' } response = requests.request("POST", url, headers=headers, data=payload) print(response.text)
require "uri" require "json" require "net/http" url = URI("https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Post.new(url) request["Accept"] = "application/json" request["Content-Type"] = "application/json" request.body = JSON.dump({ "query": "query BlockById(\$id: BlockId\!) { block(id: \$id) { id height transactions { id } } }", "variables": { "id": "0x37f8a43bc7a5c0460bd7478a41f191a74dfb3685f00e48a316d8406658dc0dad" } }) response = https.request(request) puts response.read_body
Don't have an account yet?
Create your QuickNode endpoint in seconds and start building
Get started for free