Blocks — Query Blocks
Overview
Fetch block data by height or by version.
Endpoints
GET /v1/blocks/by_height/{height}
GET /v1/blocks/by_version/{version}
Request
Parameters
Name | Type | Location | Required | Description |
---|---|---|---|---|
height | string | path | Yes | Block height |
version | string | path | Yes | Ledger version |
Response
Success Response (200)
{ "block_height": "0", "block_hash": "0x...", "first_version": "0" }
Code Examples
TypeScript (Aptos SDK)
import { Aptos, AptosConfig, Network } from '@aptos-labs/ts-sdk';
const cfg = new AptosConfig({ network: Network.CUSTOM, fullnode: 'https://api-movement-mainnet.n.dwellir.com/YOUR_API_KEY/v1' });
const aptos = new Aptos(cfg);
const block = await aptos.getBlockByHeight({ blockHeight: '0' });
console.log(block);
Python
from aptos_sdk.client import RestClient
client = RestClient('https://api-movement-mainnet.n.dwellir.com/YOUR_API_KEY/v1')
block = client.block_by_height('0')
print(block)
cURL
curl -X GET https://api-movement-mainnet.n.dwellir.com/YOUR_API_KEY/v1/blocks/by_height/0 -H "Accept: application/json"
EVM Equivalent
Use eth_getBlockByNumber
and eth_getBlockByHash
.