### Quickstart: Setup project directory for Python Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/mantle-mnt/README.md This command initializes a new project directory for the Python quickstart example. ```bash mkdir mantle-api-quickstart cd mantle-api-quickstart ``` -------------------------------- ### TypeScript gRPC Quickstart Setup Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/sui-sui/README.md Set up a new Node.js project for interacting with the Sui gRPC API using TypeScript. Installs necessary dependencies like @grpc/grpc-js and @grpc/proto-loader. ```bash mkdir sui-grpc-quickstart cd sui-grpc-quickstart npm init --yes npm install @grpc/grpc-js @grpc/proto-loader npm install -D typescript ts-node @types/node npx tsc --init ``` -------------------------------- ### JavaScript Quickstart: Setup Project Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/arc/README.md Commands to create and initialize a new Node.js project for the Arc API quickstart. ```bash mkdir arc-api-quickstart cd arc-api-quickstart npm init --yes ``` -------------------------------- ### Setup Project for Axios Quickstart Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/somnia/README.md Create and initialize a new project directory for the Somnia API quickstart using npm. ```bash mkdir somnia-api-quickstart cd somnia-api-quickstart npm init --yes ``` -------------------------------- ### JavaScript Quickstart: Make First API Call Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/avalanche-avax/README.md This example demonstrates how to make your first API call to the Avalanche C-Chain using Axios in a Node.js environment. Ensure you have Node.js, npm/yarn, and Axios installed. ```bash mkdir avalanche-api-quickstart cd avalanche-api-quickstart npm init --yes ``` ```bash npm install axios ``` ```javascript import axios from 'axios'; const data = JSON.stringify({ "jsonrpc": "2.0", "method": "eth_chainId", "params": [], "id": "getblock.io" }); const config = { method: 'post', url: 'https://go.getblock.io//ext/bc/C/rpc', headers: { 'Content-Type': 'application/json' }, data: data }; axios(config) .then(response => console.log(JSON.stringify(response.data, null, 2))) .catch(error => console.log(error)); ``` -------------------------------- ### Quickstart: Make your first API call with Axios Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/mantle-mnt/README.md This snippet demonstrates how to set up a project, install Axios, and make a JSON-RPC call to get the latest block number on the Mantle network. Replace `` with your actual GetBlock access token. ```bash mkdir mantle-api-quickstart cd mantle-api-quickstart npm init --yes ``` ```bash npm install axios ``` ```bash echo "" > index.js ``` ```json { "type": "module" } ``` ```javascript import axios from 'axios'; const data = JSON.stringify({ "jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": "getblock.io" }); const config = { method: 'post', url: 'https://go.getblock.io//', headers: { 'Content-Type': 'application/json' }, data: data }; axios(config) .then(response => console.log(JSON.stringify(response.data))) .catch(error => console.log(error)); ``` ```bash node index.js ``` ```json { "jsonrpc": "2.0", "id": "getblock.io", "result": "0x3f67f8" } ``` -------------------------------- ### JavaScript Quickstart: Setup Project Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/cosmos/README.md Set up your project directory and initialize a new Node.js project using npm. ```bash mkdir cosmos-api-quickstart cd cosmos-api-quickstart npm init --yes ``` -------------------------------- ### Get Avalanche Chain Config with Viem Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/avalanche-avax/eth_getchainconfig-avax.md This Viem example demonstrates how to get the Avalanche chain configuration. Replace '' with your GetBlock access token and ensure viem and its dependencies are installed. ```javascript import { createPublicClient, http } from 'viem'; import { avalanche } from 'viem/chains'; const client = createPublicClient({ chain: avalanche, transport: http('https://go.getblock.io//ext/bc/C/rpc') }); const result = await client.request({ method: 'eth_getChainConfig', params: [] }); console.log(result); ``` -------------------------------- ### Quickstart: Set up Python Project Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/base/README.md Prepare your project environment for making API calls to the Base network using Python and the Requests library. This involves creating a project folder and setting up a virtual environment. ```bash mkdir base-api-quickstart cd base-api-quickstart ``` ```bash python -m venv venv source venv/bin/activate # On Windows, use venv\Scripts\activate ``` ```bash pip install requests ``` -------------------------------- ### Quickstart: Get Block Number with Axios Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/base/README.md Learn how to make your first API call to get the current block number on the Base network using Axios. Ensure you have Node.js and npm installed. ```bash mkdir base-api-quickstart cd base-api-quickstart npm init --yes ``` ```bash npm install axios ``` ```javascript import axios from 'axios'; const data = JSON.stringify({ "jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": "getblock.io" }); const config = { method: 'post', url: 'https://go.getblock.io//', headers: { 'Content-Type': 'application/json' }, data: data }; axios(config) .then(response => console.log(JSON.stringify(response.data))) .catch(error => console.log(error)); ``` ```bash node index.js ``` -------------------------------- ### Get Contract Bytecode using Viem Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/avalanche-avax/eth_getcode-avax.md This Viem example demonstrates how to request contract bytecode. Ensure you have Viem installed and replace `` with your GetBlock API key. ```javascript import { createPublicClient, http } from 'viem'; import { avalanche } from 'viem/chains'; const client = createPublicClient({ chain: avalanche, transport: http('https://go.getblock.io//ext/bc/C/rpc') }); const result = await client.request({ method: 'eth_getCode', params: ["0x9e7c5e3e3a3b8e1aa0e2d4c7f9d4b0c8b8d5f1a2", "latest"] }); console.log(result); ``` -------------------------------- ### Python: Setup Monero Project Directory Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/monero-xmr/README.md Create and navigate into a new project directory for the Monero API quickstart using Python. ```bash mkdir monero-api-quickstart cd monero-api-quickstart ``` -------------------------------- ### Python Quickstart: Set up Project Directory Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/polygon-matic/README.md This Python snippet outlines the initial steps for setting up a project directory for interacting with the Polygon API. It includes creating a new directory and navigating into it. ```bash mkdir polygon-api-quickstart cd polygon-api-quickstart ``` -------------------------------- ### Get Filter Changes with Viem Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/arc/eth_getfilterchanges-arc.md This example demonstrates how to use the Viem library to call eth_getFilterChanges. Replace `` with your GetBlock API key and ensure Viem is installed. ```javascript import { createPublicClient, http, defineChain } from 'viem'; const arcTestnet = defineChain({ id: 5042002, name: 'Arc Testnet', network: 'arc-testnet', nativeCurrency: { name: 'USD Coin', symbol: 'USDC', decimals: 6 }, rpcUrls: { default: { http: ['https://go.getblock.io//'] } }, blockExplorers: { default: { name: 'arcscan', url: 'https://testnet.arcscan.app' } } }); const client = createPublicClient({ chain: arcTestnet, transport: http('https://go.getblock.io//') }); const result = await client.request({ method: 'eth_getFilterChanges', params: ["0x16f1f5f5dc91c4a1d2e7e8b6c4d3f2e1"] }); console.log(result); ``` -------------------------------- ### Get Block Number using Viem Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/worldchain/eth_blocknumber-worldchain.md This example demonstrates how to use Viem to connect to World Chain and retrieve the current block number. Make sure Viem is installed. ```javascript import { createPublicClient, http } from 'viem'; import { worldchain } from 'viem/chains'; const client = createPublicClient({ chain: worldchain, transport: http('https://go.getblock.io//') }); const blockNumber = await client.getBlockNumber(); console.log('Block Number:', blockNumber); ``` -------------------------------- ### Setup Project Directory Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/cosmos/README.md Create a new directory for your project and navigate into it. ```bash mkdir cosmos-api-quickstart cd cosmos-api-quickstart ``` -------------------------------- ### Get Avalanche Fee History with Viem Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/avalanche-avax/eth_feehistory-avax.md Shows how to retrieve fee history using the Viem library. This example requires Viem to be installed and the `` to be substituted with your API key. ```javascript import { createPublicClient, http } from 'viem'; import { avalanche } from 'viem/chains'; const client = createPublicClient({ chain: avalanche, transport: http('https://go.getblock.io//ext/bc/C/rpc') }); const result = await client.request({ method: 'eth_feeHistory', params: ["0x5", "latest", [25, 50, 75]] }); console.log(result); ``` -------------------------------- ### Javascript Quickstart: Setup Project Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/xrp-ledger/README.md Steps to set up a new Node.js project for interacting with the XRP Ledger API using Axios. ```bash mkdir xrpl-api-quickstart cd xrpl-api-quickstart npm init --yes ``` -------------------------------- ### Python Project Setup Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/worldchain/README.md Create a new directory for your World Chain API quickstart project and navigate into it using bash commands. ```bash mkdir worldchain-api-quickstart cd worldchain-api-quickstart ``` -------------------------------- ### Get Transaction Receipt with Viem Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/optimism-op/optimism_eth_gettransactionreceipt.md This example demonstrates how to retrieve a transaction receipt using the Viem library on Optimism. Replace '' with your GetBlock API key and ensure Viem is installed. ```jsx import { createPublicClient, http } from 'viem'; import { optimism } from 'viem/chains'; // Create Viem client with GetBlock const client = createPublicClient({ chain: optimism, transport: http('https://go.getblock.us/'), }); // Using the method through Viem async function Call() { try { // Method-specific Viem implementation const result = await client.request({ method: "eth_getTransactionReceipt", params: ["0xca5a3c6bcb4a1ddf5e762687816b82dbcf869b8c5a4d7301b65f33f8b0f53685"]}); console.log('Result:', result); return result; } catch (error) { console.error('Viem Error:', error); throw error; } } ``` -------------------------------- ### Get RPC Info using Axios Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/bitcoin-btc/btc_getrpcinfo.md This JavaScript example demonstrates how to use Axios to make a POST request to the GetBlock API for RPC server details. Ensure you have Axios installed. ```javascript import axios from 'axios'; const data = JSON.stringify({ "jsonrpc": "2.0", "method": "getrpcinfo", "params": [], "id": "getblock.io" }); const config = { method: 'post', url: 'https://go.getblock.io//', headers: { 'Content-Type': 'application/json' }, data : data }; axios(config) .then(response => console.log(JSON.stringify(response.data))) .catch(error => console.log(error)); ``` -------------------------------- ### Create Project Directory Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/sei/README.md Set up a new directory for the Sei API quickstart project. ```bash mkdir sei-api-quickstart cd sei-api-quickstart ``` -------------------------------- ### Set up Python Project Directory Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/arbitrum-arb/README.md Creates a new project directory for the Python quickstart. ```bash mkdir arbitrum-api-quickstart cd arbitrum-api-quickstart ``` -------------------------------- ### Get Block Details with Viem Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/base/eth_getblockbynumber-base.md This Viem example demonstrates how to retrieve block data, excluding transactions by default. Replace '' with your GetBlock API key and ensure Viem is installed. ```javascript import { createPublicClient, http } from 'viem'; import { base } from 'viem/chains'; const client = createPublicClient({ chain: base, transport: http('https://go.getblock.io//') }); async function getBlock(blockNumber = 'latest') { const block = await client.getBlock({ blockNumber: blockNumber === 'latest' ? undefined : BigInt(blockNumber), includeTransactions: false }); console.log('Block Number:', block.number); console.log('Hash:', block.hash); console.log('Timestamp:', new Date(Number(block.timestamp) * 1000)); console.log('Transactions:', block.transactions.length); return block; } getBlock(); ``` -------------------------------- ### Get Solana Slot Leaders using cURL Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/solana-sol/getslotleaders-rpc-method-solana.md This example demonstrates how to call the getSlotLeaders RPC method using cURL. It specifies a start slot of 100 and requests 10 slot leaders. ```json curl --location "https://go.getblock.io//" -XPOST \ --header "Content-Type: application/json" \ --data '{ "jsonrpc": "2.0", "id": 1, "method": "getSlotLeaders", "params": [100, 10] }' ``` -------------------------------- ### Initialize Project and Install Dependencies Source: https://github.com/getblock-io/getblock-docs/blob/main/guides/how-to-build-basic-level-model-context-protocol-with-getblock-api-endpoints.md Sets up a new project directory, initializes npm, and installs necessary MCP SDK, Zod, and Ethers libraries. ```bash # create project folder mkdir basic-ethereum-mcp # navigate through the folder cd basic-ethereum-mcp # initialise npm npm init -y npm install @modelcontextprotocol/sdk zod ethers ``` -------------------------------- ### JavaScript Quickstart: Make First API Call Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/arc/README.md Example code using Axios to make a POST request to the Arc API to get the chain ID. Replace with your actual token. ```javascript import axios from 'axios'; const data = JSON.stringify({ "jsonrpc": "2.0", "method": "eth_chainId", "params": [], "id": "getblock.io" }); const config = { method: 'post', url: 'https://go.getblock.io//', headers: { 'Content-Type': 'application/json' }, data: data }; axios(config) .then(response => console.log(JSON.stringify(response.data, null, 2))) .catch(error => console.log(error)); ``` -------------------------------- ### Create Project Directory Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/bnb-smart-chain-bsc/README.md Set up a new directory for the BSC API quickstart project. ```bash mkdir bsc-api-quickstart cd bsc-api-quickstart ``` -------------------------------- ### Get Stellar Transaction Details using JavaScript (axios) Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/stellar-xlm/gettransaction-stellar.md This JavaScript example uses the axios library to request Stellar transaction details from the GetBlock API. Ensure you have axios installed and replace ``. ```javascript import axios from 'axios'; const data = JSON.stringify({ "jsonrpc": "2.0", "method": "getTransaction", "params": { "hash": "d8ec9b68780314ffdfdfc2194b1b35dd27d7303c3bceaef6447e31631a1419dc" }, "id": "getblock.io" }); const config = { method: 'post', url: 'https://go.getblock.io//', headers: { 'Content-Type': 'application/json' }, data : data }; axios(config) .then(response => console.log(JSON.stringify(response.data))) .catch(error => console.log(error)); ``` -------------------------------- ### Start the Server Source: https://github.com/getblock-io/getblock-docs/blob/main/guides/how-to-build-a-pay-per-request-blockchain-api-with-x402-and-getblock.md Navigate to the server directory and start the application using npm. ```bash cd server npm start ``` -------------------------------- ### Get Transaction Receipt with Viem on opBNB Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/optimistic-bnb-smart-chain-opbnb/eth_gettransactionreceipt-opbnb.md This example shows how to retrieve a transaction receipt using the Viem library on the opBNB chain. Replace '' with your GetBlock API key and ensure Viem is installed. ```javascript import { createPublicClient, http } from 'viem'; import { opBNB } from 'viem/chains'; const client = createPublicClient({ chain: opBNB, transport: http('https://go.getblock.io//') }); const result = await client.request({ method: 'eth_getTransactionReceipt', params: ["0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"] }); console.log(result); ``` -------------------------------- ### Initialize Project and Install Requests Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/the-open-network-ton/README.md Sets up a Python project directory, creates a virtual environment, and installs the Requests library. ```bash mkdir ton-api-quickstart cd ton-api-quickstart python -m venv venv source venv/bin/activate # On Windows, use: virtualenv\Scripts\activate pip install requests ``` -------------------------------- ### Get Celo Account Balance (JavaScript Axios) Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/celo/eth_getbalance-celo.md This JavaScript example uses Axios to make a POST request to the GetBlock API for eth_getBalance. Ensure you have Axios installed and replace with your API key. ```javascript const axios = require('axios'); const url = 'https://go.getblock.io//'; const payload = { jsonrpc: '2.0', id: 'getblock.io', method: 'eth_getBalance', params: [ '0x742d35Cc6634C0532925a3b844Bc9e7595f8bB45', 'latest' ] }; axios.post(url, payload, { headers: { 'Content-Type': 'application/json' } }) .then(response => console.log(response.data)) .catch(error => console.error(error)); ``` -------------------------------- ### JavaScript Quickstart: Create Index File Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/cosmos/README.md Create the main JavaScript file where the API call will be implemented. ```bash Create a new file named `index.js`. This is where you will make your first call. ``` -------------------------------- ### Initialize Monero Project Directory Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/monero-xmr/README.md Create and initialize a new project directory for Monero API quickstart. ```bash mkdir monero-api-quickstart cd monero-api-quickstart npm init --yes ``` -------------------------------- ### Python (Requests) Quickstart Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/zksync/README.md This snippet demonstrates how to set up a Python project and install the requests library for making API calls. ```APIDOC ## Python Project Setup for API Calls ### Description This guide outlines the steps to set up a Python project and install the necessary libraries to interact with the zkSync Era API. ### Steps 1. **Create Project Directory**: ```bash mkdir zksync-api-quickstart cd zksync-api-quickstart ``` 2. **Create and Activate Virtual Environment**: ```bash python -m venv venv source venv/bin/activate # On Windows, use venv\Scripts\activate ``` 3. **Install Requests Library**: ```bash pip install requests ``` After completing these steps, you can proceed to write Python code to make API requests to the zkSync Era network. ``` -------------------------------- ### Get SEI Account Balance with JavaScript (axios) Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/sei/eth_getbalance-sei.md This JavaScript example uses the axios library to fetch an account's SEI balance. Ensure you have axios installed and replace with your GetBlock API key. ```javascript import axios from 'axios'; const url = 'https://go.getblock.io//'; const payload = { jsonrpc: '2.0', method: 'eth_getBalance', params: ["0x742d35Cc6634C0532925a3b844Bc9e7595f5bE21", "latest"], id: 'getblock.io' }; axios.post(url, payload, { headers: { 'Content-Type': 'application/json' } }) .then(response => console.log(response.data)) .catch(error => console.error(error)); ``` -------------------------------- ### Get opBNB Client Version using Viem Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/optimistic-bnb-smart-chain-opbnb/web3_clientversion-opbnb.md This Viem example demonstrates how to request the client version from opBNB using the `createPublicClient` function. Ensure you have Viem installed and replace `` with your GetBlock access token. ```javascript import { createPublicClient, http } from 'viem'; import { opBNB } from 'viem/chains'; const client = createPublicClient({ chain: opBNB, transport: http('https://go.getblock.io//') }); const result = await client.request({ method: 'web3_clientVersion', params: [] }); console.log(result); ``` -------------------------------- ### Setup JavaScript Project Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/optimistic-bnb-smart-chain-opbnb/README.md Create and initialize a new Node.js project for opBNB API interaction. ```bash mkdir opbnb-api-quickstart cd opbnb-api-quickstart npm init --yes ``` -------------------------------- ### Get Block Transaction Count by Hash with Viem Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/arc/eth_getblocktransactioncountbyhash-arc.md Integrate Viem with GetBlock to fetch the transaction count for a block using its hash. This example sets up a custom chain configuration for Arc Testnet. Ensure Viem is installed. ```javascript import { createPublicClient, http, defineChain } from 'viem'; const arcTestnet = defineChain({ id: 5042002, name: 'Arc Testnet', network: 'arc-testnet', nativeCurrency: { name: 'USD Coin', symbol: 'USDC', decimals: 6 }, rpcUrls: { default: { http: ['https://go.getblock.io//'] } }, blockExplorers: { default: { name: 'arcscan', url: 'https://testnet.arcscan.app' } } }); const client = createPublicClient({ chain: arcTestnet, transport: http('https://go.getblock.io//') }); const result = await client.request({ method: 'eth_getBlockTransactionCountByHash', params: ["0x4f3a1d6e8c2b9a7e5d3f1c8a4b6e9d2f5a8c3e7b1d4f9a6c2e5b8d3f7a1c4e9b"] }); console.log(result); ``` -------------------------------- ### JavaScript (Axios) Quickstart - Create and Initialize Project Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/midnight/README.md Steps to create and initialize a new Node.js project for the Midnight API quickstart using npm. ```bash mkdir midnight-api-quickstart cd midnight-api-quickstart npm init --yes ``` -------------------------------- ### Get Arbitrum Client Version using Axios (JavaScript) Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/arbitrum-arb/arbitrum_web3_clientversion.md This JavaScript example demonstrates how to fetch the Arbitrum client version using the Axios library. Ensure you have Axios installed and replace with your GetBlock access token. ```javascript import axios from 'axios' let data = JSON.stringify({ "jsonrpc": "2.0", "method": "web3_clientVersion", "params": [], "id": "getblock.io" }; let config = { method: "post", maxBodyLength: Infinity, url: "https://go.getblock.us/", headers: { "Content-Type": "application/json", }, data: data, }; axios .request(config) .then((response) => { console.log(JSON.stringify(response.data)); }) .catch((error) => { console.log(error); }); ``` -------------------------------- ### Initialize Project and Install Axios Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/the-open-network-ton/README.md Sets up a new Node.js project and installs the Axios library for making HTTP requests. ```bash mkdir ton-api-quickstart cd ton-api-quickstart npm init --yes npm install axios ``` -------------------------------- ### Python Quickstart: Create Script and Make API Call Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/arc/README.md Example Python code using the Requests library to make a POST request to the Arc API to get the chain ID. Replace with your actual token. ```python import requests import json url = "https://go.getblock.io/ρες" payload = json.dumps({ "jsonrpc": "2.0", "method": "eth_chainId", "params": [], "id": "getblock.io" }) headers = { 'Content-Type': 'application/json' } response = requests.post(url, headers=headers, data=payload) print(response.text) ``` -------------------------------- ### Python Quickstart with Requests Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/monero-xmr/README.md Make your first Monero API call using Python and the Requests library. Ensure you have Python and pip installed. ```python import requests GETBLOCK_API_KEY = 'YOUR_GETBLOCK_API_KEY' # Replace with your API key MONERO_NODE_URL = f'https://go.getblock.io/{GETBLOCK_API_KEY}/' def get_block_count(): payload = { "jsonrpc": "2.0", "method": "get_block_count", "id": 1 } try: response = requests.post(MONERO_NODE_URL, json=payload) response.raise_for_status() # Raise an exception for bad status codes print(f"Block count: {response.json()['result']}") return response.json()['result'] except requests.exceptions.RequestException as e: print(f"Error fetching block count: {e}") raise get_block_count() ``` -------------------------------- ### Get Stellar Health Status using JavaScript (axios) Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/stellar-xlm/gethealth-stellar.md This JavaScript example uses the axios library to make a POST request to the Stellar RPC endpoint for health status. Ensure you have axios installed and replace with your token. ```javascript import axios from 'axios'; const data = JSON.stringify({ "jsonrpc": "2.0", "method": "getHealth", "id": "getblock.io" }); const config = { method: 'post', url: 'https://go.getblock.io//', headers: { 'Content-Type': 'application/json' }, data: data }; axios(config) .then(response => console.log(JSON.stringify(response.data))) .catch(error => console.log(error)); ``` -------------------------------- ### Get Latest Stellar Ledger using JavaScript (axios) Source: https://github.com/getblock-io/getblock-docs/blob/main/api-reference/stellar-xlm/getlatestledger-stellar.md This JavaScript example demonstrates how to fetch the latest Stellar ledger information using the `axios` library. Ensure you have `axios` installed and replace `` with your GetBlock API key. ```javascript import axios from 'axios'; const data = JSON.stringify({ "jsonrpc": "2.0", "method": "getLatestLedger", "id": "getblock.io" }); const config = { method: 'post', url: 'https://go.getblock.io//', headers: { 'Content-Type': 'application/json' }, data : data }; axios(config) .then(response => console.log(JSON.stringify(response.data))) .catch(error => console.log(error)); ```