getBlockByHeight Query
Paramètres
Hauteur
chaîne de caractères
OBLIGATOIRE
Chargement...
Renvoie
données
objet
Chargement...
bloc
objet
Chargement...
ID
chaîne de caractères
Chargement...
Requête
1curl --location 'https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql' \2--en-tête 'Accept: application/json' \3--header 'Content-Type: application/json' \4--data '{5"query": "query Block($height: U64) { block(height: $height) { id } }",6"variables": {7"height": "3412"8}9}'
1curl --location 'https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql' \2--en-tête 'Accept: application/json' \3--header 'Content-Type: application/json' \4--data '{5"query": "query Block($height: U64) { block(height: $height) { id } }",6"variables": {7"height": "3412"8}9}'
1const BLOCK_QUERY = `2query Block($height: U64) {3block(height: $height) {4ID5}6}7`;89const QUERY_VARIABLES = {10height: '3412',11};1213const fetchBlockByHeight = async () => {14essayer {15const response = await fetch('https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql', {16méthode: « POST »,17headers: {18« Accepter »: 'application/json',19« Content-Type »: 'application/json',20},21body: JSON.stringify({22requête: BLOCK_QUERY,23variables: QUERY_VARIABLES,24}),25});2627si (!réponse.ok) {28throw new Error(`HTTP error! status: ${response.status}`);29}3031const résultat = await response.json();32console.journal('ID du bloc :', résultat.données.bloc.id);33} catch (erreur) {34console.error('Error fetching block:', error);35}36};3738fetchBlockByHeight();39
1const BLOCK_QUERY = `2query Block($height: U64) {3block(height: $height) {4ID5}6}7`;89const QUERY_VARIABLES = {10height: '3412',11};1213const fetchBlockByHeight = async () => {14essayer {15const response = await fetch('https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql', {16méthode: « POST »,17headers: {18« Accepter »: 'application/json',19« Content-Type »: 'application/json',20},21body: JSON.stringify({22requête: BLOCK_QUERY,23variables: QUERY_VARIABLES,24}),25});2627si (!réponse.ok) {28throw new Error(`HTTP error! status: ${response.status}`);29}3031const résultat = await response.json();32console.journal('ID du bloc :', résultat.données.bloc.id);33} catch (erreur) {34console.error('Error fetching block:', error);35}36};3738fetchBlockByHeight();39
1const myHeaders = new Headers();2myHeaders.append("Accept", "application/json");3mesEnTêtes.ajouter("Content-Type", "application/json");45const brut = JSON.stringify({6"query": "query Block($height: U64) { block(height: $height) { id } }",7"variables": {8"height": "3412"9}10});1112const requestOptions = {13méthode: « POST »,14headers: myHeaders,15body: raw,16redirect: "follow"17};1819récupérer(« https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql », requestOptions)20.then((response) => response.text())21.then((result) => console.log(result))22.catch((error) => console.error(error));
1const myHeaders = new Headers();2myHeaders.append("Accept", "application/json");3mesEnTêtes.ajouter("Content-Type", "application/json");45const brut = JSON.stringify({6"query": "query Block($height: U64) { block(height: $height) { id } }",7"variables": {8"height": "3412"9}10});1112const requestOptions = {13méthode: « POST »,14headers: myHeaders,15body: raw,16redirect: "follow"17};1819récupérer(« https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql », requestOptions)20.then((response) => response.text())21.then((result) => console.log(result))22.catch((error) => console.error(error));
1const { ApolloClient, InMemoryCache, gql } = require('@apollo/client/core');2const fetch = require('cross-fetch');34const client = new ApolloClient({5uri: « https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql »,6cache: new InMemoryCache(),7récupérer: récupérer,8headers: {9« Accepter »: 'application/json',10« Content-Type »: 'application/json'11}12});1314const BLOCK_BY_HEIGHT_QUERY = gql`15query Block($height: U64) {16block(height: $height) {17ID18}19}20`;2122const variables = {23height: "3412"24};2526client.requête({27query: BLOCK_BY_HEIGHT_QUERY,28variables: variables29})30.puis(résultat => {31console.journal(JSON.stringify(result.data, null, 2));32})33.catch(erreur => console.erreur('Erreur :', erreur));
1const { ApolloClient, InMemoryCache, gql } = require('@apollo/client/core');2const fetch = require('cross-fetch');34const client = new ApolloClient({5uri: « https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql »,6cache: new InMemoryCache(),7récupérer: récupérer,8headers: {9« Accepter »: 'application/json',10« Content-Type »: 'application/json'11}12});1314const BLOCK_BY_HEIGHT_QUERY = gql`15query Block($height: U64) {16block(height: $height) {17ID18}19}20`;2122const variables = {23height: "3412"24};2526client.requête({27query: BLOCK_BY_HEIGHT_QUERY,28variables: variables29})30.puis(résultat => {31console.journal(JSON.stringify(result.data, null, 2));32})33.catch(erreur => console.erreur('Erreur :', erreur));
1import requests2import json34url = « https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql »56payload = json.dumps({7"query": "query Block($height: U64) { block(height: $height) { id } }",8"variables": {9"height": "3412"10}11})12headers = {13'Accept': 'application/json',14'Content-Type': 'application/json'15}1617response = requests.request("POST", url, headers=headers, data=payload)1819print(response.text)20
1import requests2import json34url = « https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql »56payload = json.dumps({7"query": "query Block($height: U64) { block(height: $height) { id } }",8"variables": {9"height": "3412"10}11})12headers = {13'Accept': 'application/json',14'Content-Type': 'application/json'15}1617response = requests.request("POST", url, headers=headers, data=payload)1819print(response.text)20
1require "uri"2require "json"3require "net/http"45url = URI(« https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql »)67https = Net::HTTP.new(url.host, url.port)8https.use_ssl = true910request = Net::HTTP::Post.new(url)11request["Accept"] = "application/json"12request["Content-Type"] = "application/json"13request.body = JSON.dump({14"query": "query Block(\$height: U64) { block(height: \$height) { id } }",15"variables": {16"height": "3412"17}18})1920response = https.request(request)21puts response.read_body22
1require "uri"2require "json"3require "net/http"45url = URI(« https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql »)67https = Net::HTTP.new(url.host, url.port)8https.use_ssl = true910request = Net::HTTP::Post.new(url)11request["Accept"] = "application/json"12request["Content-Type"] = "application/json"13request.body = JSON.dump({14"query": "query Block(\$height: U64) { block(height: \$height) { id } }",15"variables": {16"height": "3412"17}18})1920response = https.request(request)21puts response.read_body22
Vous n'avez pas encore de compte ?
Créez votre endpoint Quicknode en quelques secondes et commencez à développer
Commencez gratuitement