---
title: "Get a range of blocks with optional decoded transactions and logs"
method: POST
path: "/?ankr_getBlocks"
tags: ["Query API"]
---

# Get a range of blocks with optional decoded transactions and logs

`POST /?ankr_getBlocks`

## Request

- Base URL: `https://rpc.ankr.com/multichain/569ca1f392f7d3d0bb1073a1173ecb649af1d9249231fe59fa95db19d5ae41fe`
- URL: `https://rpc.ankr.com/multichain/569ca1f392f7d3d0bb1073a1173ecb649af1d9249231fe59fa95db19d5ae41fe/?ankr_getBlocks`
- Auth: none declared
- TypeScript: <https://skmtc.dev/ankr/apis/ankr-advanced-api/docs/%3Fankr_getBlocks/post.ts> (a function with typed inputs; its response is checked against the schema)

Returns details for the requested range of blocks on a single chain: header fields, the full transaction list (optional), and per-transaction logs (optional). Use the `decodeTxData` and `decodeLogs` flags to receive resolved method/event signatures and decoded inputs.

Pass `blockchain`, then `fromBlock` and `toBlock` as either integers, hex strings, or the keywords `earliest` / `latest`. **Maximum range is 30 blocks per call.** `includeLogs` requires `includeTxs` to also be true.

Part of the **Query API** product (700 compute units per call, $0.00007 at base rate).

## Request body

- object
  - `id` integer, required: Client-supplied request ID echoed in the response.
  - `jsonrpc` '2.0', required
  - `method` 'ankr_getBlocks', required
  - `params` object, required
    - `blockchain` 'arbitrum' | 'avalanche' | 'base' | 'bsc' | 'eth' | 'fantom' | 'flare' | 'gnosis' | 'linea' | 'optimism' | 'polygon' | 'scroll' | 'somnia_mainnet' | 'taiko' | 'telos' | 'xlayer' | 'avalanche_fuji' | 'base_sepolia' | 'eth_sepolia' | 'optimism_sepolia' | 'polygon_amoy', required: Target blockchain identifier.
    - `fromBlock` union: First block (inclusive). Integer, hex string, or `earliest`. Max range — 30 blocks.
      - integer
      - string
    - `toBlock` union: Last block (inclusive). Integer, hex string, or `latest`. Max range — 30 blocks.
      - integer
      - string
    - `decodeLogs` boolean: Resolve event signatures and decode log inputs.
    - `decodeTxData` boolean: Resolve method signatures and decode transaction inputs.
    - `descOrder` boolean: Sort newest first when `true`.
    - `includeLogs` boolean: Include logs inside transactions. Requires `includeTxs: true`.
    - `includeTxs` boolean: Include transaction objects in each block.

## Response `200`

Success. JSON-RPC `result` contains the `blocks` array. JSON-RPC errors are returned with HTTP 200; check the response body for an `error` key.

- object
  - `id` integer, required
  - `jsonrpc` '2.0', required
  - `result` object, required
    - `blocks` object[], nullable: Block objects in the requested range.
      - `blockchain` string, required
      - `number` string, required: Block number, hex-encoded.
      - `hash` string, required
      - `parentHash` string, required
      - `nonce` string, required
      - `mixHash` string, required
      - `sha3Uncles` string, required
      - `logsBloom` string, required
      - `stateRoot` string, required
      - `transactionsRoot` string, required
      - `receiptsRoot` string, required
      - `miner` string, required
      - `difficulty` string, required
      - `totalDifficulty` string, required
      - `extraData` string, required
      - `size` string, required
      - `gasLimit` string, required
      - `gasUsed` string, required
      - `timestamp` string, required: UNIX timestamp, hex-encoded.
      - `transactions` object[], nullable, required: Transaction objects or hashes depending on `includeTxs`.
      - `uncles` string[], nullable, required: Uncle block hashes.

## Other responses

- `400`: Bad Request — malformed JSON-RPC envelope or invalid `params`. The gateway rejects before the JSON-RPC layer processes the call.
- `401`: Unauthorized — missing or invalid API key in the server URL path. Verify that `{API_KEY}` is set to a valid project key.
- `429`: Too Many Requests — the API key has exceeded its rate or quota limits. Back off and retry; consider upgrading the Premium tier for higher limits.
- `500`: Server error — unexpected condition. Retry with exponential backoff; if it persists, file a ticket at https://www.ankr.com/support/.

---

[API](https://skmtc.dev/ankr/apis/ankr-advanced-api.md) - [All operations](https://skmtc.dev/ankr/apis/ankr-advanced-api/llms.txt) - [OpenAPI document](https://skmtc.dev/ankr/apis/ankr-advanced-api/revisions/77e494aeec1b?raw)
