getBlockByHeight Query
參數
高度
字串
必填
載入中...
退貨
資料
物件
載入中...
區塊
物件
載入中...
id
字串
載入中...
請求
1curl --location 'https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql' \2--header 'Accept: application/json' \3--標頭 '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--header 'Accept: application/json' \3--標頭 '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 () => {14試試看 {15const response = await fetch('https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql', {16方法: 'POST',17headers: {18「接受」: 'application/json',19「Content-Type」: 'application/json',20},21body: JSON.stringify({22query: BLOCK_QUERY,23變數: 查詢變數:,24}),25});2627如果 (!回應.ok) {28throw new Error(`HTTP error! status: ${response.status}`);29}3031const 結果 = await response.json();32console.log('Block ID:', result.data.block.id);33} catch (錯誤) {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 () => {14試試看 {15const response = await fetch('https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql', {16方法: 'POST',17headers: {18「接受」: 'application/json',19「Content-Type」: 'application/json',20},21body: JSON.stringify({22query: BLOCK_QUERY,23變數: 查詢變數:,24}),25});2627如果 (!回應.ok) {28throw new Error(`HTTP error! status: ${response.status}`);29}3031const 結果 = await response.json();32console.log('Block ID:', result.data.block.id);33} catch (錯誤) {34console.error('Error fetching block:', error);35}36};3738fetchBlockByHeight();39
1const myHeaders = new Headers();2myHeaders.追加("Accept", "application/json");3myHeaders.追加("Content-Type", "application/json");45const raw = JSON.stringify({6"query": "query Block($height: U64) { block(height: $height) { id } }",7"variables": {8"height": "3412"9}10});1112const requestOptions = {13方法: 「POST」,14標題: myHeaders,15正文: 原始,16重定向: 「追蹤」17};1819取得(「https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql」, requestOptions)20.接著((回應) => 回應.文字())21.接著((結果) => 控制台.log(結果))22.catch((錯誤) => 控制台.錯誤(錯誤));
1const myHeaders = new Headers();2myHeaders.追加("Accept", "application/json");3myHeaders.追加("Content-Type", "application/json");45const raw = JSON.stringify({6"query": "query Block($height: U64) { block(height: $height) { id } }",7"variables": {8"height": "3412"9}10});1112const requestOptions = {13方法: 「POST」,14標題: myHeaders,15正文: 原始,16重定向: 「追蹤」17};1819取得(「https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql」, requestOptions)20.接著((回應) => 回應.文字())21.接著((結果) => 控制台.log(結果))22.catch((錯誤) => 控制台.錯誤(錯誤));
1const { ApolloClient, InMemoryCache, gql } = require('@apollo/client/core');2const fetch = require('cross-fetch');34const 客戶端 = new ApolloClient({5uri: 《https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql》,6快取: new InMemoryCache(),7fetch: fetch,8headers: {9「接受」: '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 變數 = {23height: "3412"24};2526客戶.查詢({27query: BLOCK_BY_HEIGHT_QUERY,28變數: 變數29})30.接著(結果 => {31console.log(JSON.stringify(result.data, null, 2));32})33.catchcatch(錯誤 => console.錯誤('錯誤:', 錯誤));
1const { ApolloClient, InMemoryCache, gql } = require('@apollo/client/core');2const fetch = require('cross-fetch');34const 客戶端 = new ApolloClient({5uri: 《https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql》,6快取: new InMemoryCache(),7fetch: fetch,8headers: {9「接受」: '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 變數 = {23height: "3412"24};2526客戶.查詢({27query: BLOCK_BY_HEIGHT_QUERY,28變數: 變數29})30.接著(結果 => {31console.log(JSON.stringify(result.data, null, 2));32})33.catchcatch(錯誤 => console.錯誤('錯誤:', 錯誤));
1匯入 請求2import json34網址 = "https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql"56有效載荷 = json.dumps({7"query": "query Block($height: U64) { block(height: $height) { id } }",8"variables": {9"height": "3412"10}11})12標題 = {13「接受」: 'application/json',14「Content-Type」: 'application/json'15}1617回應 = 請求.請求("POST", url, headers=headers, data=有效載荷)1819列印(回應.text)20
1匯入 請求2import json34網址 = "https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql"56有效載荷 = json.dumps({7"query": "query Block($height: U64) { block(height: $height) { id } }",8"variables": {9"height": "3412"10}11})12標題 = {13「接受」: 'application/json',14「Content-Type」: 'application/json'15}1617回應 = 請求.請求("POST", url, headers=headers, data=有效載荷)1819列印(回應.text)20
1需要 "uri"2require "json"3需要 "net/http"45網址 = URI("https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql")67https = 網::HTTP.new(url.主機, url.port)8https.use_ssl = true910請求 = 淨::HTTP::POST.new(網址)11請求[「接受」] = "application/json"12請求["Content-Type"] = "application/json"13請求。正文 = JSON.dump({14"query": "query Block(\$height: U64) { block(height: \$height) { id } }",15"variables": {16"height": "3412"17}18})1920回應 = https.請求(請求)21將回應。read_body22
1需要 "uri"2require "json"3需要 "net/http"45網址 = URI("https://docs-demo.fuel-mainnet.quiknode.pro/v1/graphql")67https = 網::HTTP.new(url.主機, url.port)8https.use_ssl = true910請求 = 淨::HTTP::POST.new(網址)11請求[「接受」] = "application/json"12請求["Content-Type"] = "application/json"13請求。正文 = JSON.dump({14"query": "query Block(\$height: U64) { block(height: \$height) { id } }",15"variables": {16"height": "3412"17}18})1920回應 = https.請求(請求)21將回應。read_body22