API ReferenceBlocks APIGet block by versionVersion: 2.0Get block by versionMainnetTestnetGEThttps://mainnet-aptos-api.moralis.io/blocks/by_version/:versionGet block by specific ledger version.PATH PARAMSversionnumberrequiredLedger version to lookup block information for.QUERY PARAMSwith_transactionsbooleanIf set to true, include all transactions in the blockfalsetrueResponses200 Returns block by versionobjectAPI KEYTry ItNode.jsPythoncURLGoPHPimport Moralis from 'moralis';try { await Moralis.start({ apiKey: "YOUR_API_KEY" }); const response = await Moralis.AptosApi.blocks.getBlockByVersion({}); console.log(response);} catch (e) { console.error(e);}from moralis import aptos_apiapi_key = "YOUR_API_KEY"params = {}result = aptos_api.blocks.get_block_by_version( api_key=api_key, params=params,)print(result)curl --request GET \ --url 'https://mainnet-aptos-api.moralis.io/blocks/by_version/%3Aversion' \ --header 'accept: application/json' \ --header 'X-API-Key: YOUR_API_KEY' package mainimport ( "fmt" "net/http" "io/ioutil")func main() { url := "https://mainnet-aptos-api.moralis.io/blocks/by_version/%3Aversion" req, _ := http.NewRequest("GET", url, payload) req.Header.Add("Accept", "application/json") req.Header.Add("X-API-Key", "YOUR_API_KEY") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body))}<?php// Dependencies to install:// $ composer require guzzlehttp/guzzlerequire_once('vendor/autoload.php');$client = new \GuzzleHttp\Client();$response = $client->request('GET', 'https://mainnet-aptos-api.moralis.io/blocks/by_version/%3Aversion', [ 'headers' => [ 'Accept' => 'application/json', 'X-API-Key' => 'YOUR_API_KEY', ],]);echo $response->getBody();Response Example200 Returns block by version{ "block_height": "32425224034", "block_hash": "32425224034", "block_timestamp": "32425224034", "first_version": "32425224034", "last_version": "32425224034", "transactions": [ { "hash": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "sender": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "sequence_number": "32425224034", "max_gas_amount": "32425224034", "gas_unit_price": "32425224034", "expiration_timestamp_secs": "32425224034" }, { "type": "", "version": "32425224034", "hash": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": "", "gas_used": "32425224034", "success": true, "vm_status": "", "accumulator_root_hash": "", "changes": [ { "type": "delete_module", "address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "state_key_hash": "" }, { "type": "delete_module", "address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "state_key_hash": "" }, { "type": "delete_module", "state_key_hash": "", "data": { "key": "", "key_type": "" } }, { "type": "delete_module", "address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "state_key_hash": "", "data": { "bytecode": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "abi": { "address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "name": "", "exposed_functions": [ { "name": "", "visibility": "private", "is_entry": true } ], "structs": [ { "name": "", "is_native": true, "fields": [ { "name": "sender", "type": "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>" } ] } ] } } }, { "type": "delete_module", "address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "state_key_hash": "", "data": { "type": "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>" } }, { "type": "delete_module", "state_key_hash": "", "handle": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "key": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "value": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "data": { "key": "", "key_type": "", "value": "", "value_type": "" } } ], "sender": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "sequence_number": "32425224034", "max_gas_amount": "32425224034", "gas_unit_price": "32425224034", "expiration_timestamp_secs": "32425224034", "events": [ { "guid": { "creation_number": "32425224034", "account_address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1" }, "sequence_number": "32425224034", "type": "0x1::account::Account" } ], "timestamp": "32425224034" }, { "type": "genesis_transaction", "version": "32425224034", "hash": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": "", "gas_used": "32425224034", "success": true, "vm_status": "", "accumulator_root_hash": "", "changes": [ { "type": "delete_module", "address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "state_key_hash": "" }, { "type": "delete_module", "address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "state_key_hash": "" }, { "type": "delete_module", "state_key_hash": "", "data": { "key": "", "key_type": "" } }, { "type": "delete_module", "address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "state_key_hash": "", "data": { "bytecode": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "abi": { "address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "name": "", "exposed_functions": [ { "name": "", "visibility": "private", "is_entry": true } ], "structs": [ { "name": "", "is_native": true, "fields": [ { "name": "sender", "type": "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>" } ] } ] } } }, { "type": "delete_module", "address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "state_key_hash": "", "data": { "type": "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>" } }, { "type": "delete_module", "state_key_hash": "", "handle": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "key": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "value": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "data": { "key": "", "key_type": "", "value": "", "value_type": "" } } ], "events": [ { "guid": { "creation_number": "32425224034", "account_address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1" }, "sequence_number": "32425224034", "type": "0x1::account::Account" } ] }, { "type": "block_metadata_transaction", "version": "32425224034", "hash": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": "", "gas_used": "32425224034", "success": true, "vm_status": "", "accumulator_root_hash": "", "changes": [ { "type": "delete_module", "address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "state_key_hash": "" }, { "type": "delete_module", "address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "state_key_hash": "" }, { "type": "delete_module", "state_key_hash": "", "data": { "key": "", "key_type": "" } }, { "type": "delete_module", "address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "state_key_hash": "", "data": { "bytecode": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "abi": { "address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "name": "", "exposed_functions": [ { "name": "", "visibility": "private", "is_entry": true } ], "structs": [ { "name": "", "is_native": true, "fields": [ { "name": "sender", "type": "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>" } ] } ] } } }, { "type": "delete_module", "address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "state_key_hash": "", "data": { "type": "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>" } }, { "type": "delete_module", "state_key_hash": "", "handle": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "key": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "value": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "data": { "key": "", "key_type": "", "value": "", "value_type": "" } } ], "id": "", "epoch": "32425224034", "round": "32425224034", "events": [ { "guid": { "creation_number": "32425224034", "account_address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1" }, "sequence_number": "32425224034", "type": "0x1::account::Account" } ], "proposer": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "timestamp": "32425224034" }, { "type": "state_checkpoint_transaction", "version": "32425224034", "hash": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": "", "gas_used": "32425224034", "success": true, "vm_status": "", "accumulator_root_hash": "", "changes": [ { "type": "delete_module", "address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "state_key_hash": "" }, { "type": "delete_module", "address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "state_key_hash": "" }, { "type": "delete_module", "state_key_hash": "", "data": { "key": "", "key_type": "" } }, { "type": "delete_module", "address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "state_key_hash": "", "data": { "bytecode": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "abi": { "address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "name": "", "exposed_functions": [ { "name": "", "visibility": "private", "is_entry": true } ], "structs": [ { "name": "", "is_native": true, "fields": [ { "name": "sender", "type": "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>" } ] } ] } } }, { "type": "delete_module", "address": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "state_key_hash": "", "data": { "type": "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>" } }, { "type": "delete_module", "state_key_hash": "", "handle": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "key": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "value": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1", "data": { "key": "", "key_type": "", "value": "", "value_type": "" } } ], "timestamp": "32425224034" } ]}