blocks - Ethereum Classic

Returns all blocks in an inclusive range from a starting number to an ending number (or the latest), each with the fields you select. Useful for batch indexing.

Schema

graphqlblocks(from: Long!, to: Long): [Block!]!

Arguments

ArgumentTypeDescription
fromLong!First block number (inclusive)
toLongLast block number (inclusive); omit for the latest

Query

graphqlquery {
  blocks(from: 21200000, to: 21200005) {
    number
    transactionCount
    gasUsed
  }
}

Example

bashexport ETC_GRAPHQL=https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/

curl --location --request POST "${ETC_GRAPHQL}graphql" \
--header 'Content-Type: application/json' \
--data-raw '{"query": "query { blocks(from: 21200000, to: 21200005) { number transactionCount gasUsed } }"}'

Response

json{
    "data": {
        "blocks": [
            {
                "number": 21200000,
                "transactionCount": 12,
                "gasUsed": 1200000
            },
            {
                "number": 21200001,
                "transactionCount": 8,
                "gasUsed": 800000
            }
        ]
    }
}

Response Fields

FieldTypeDescription
[Block]arrayBlocks in the requested range, each with selected fields

Use Cases

  • Batch Indexing: Ingest a block range in one request
  • Backfill: Replay history for an indexer
  • Analytics: Aggregate metrics across blocks

Error Handling

ErrorMessageDescription
errors[]range too largeThe requested range exceeds the node's limit
403 / RBAC: access deniedAccess deniedThe GetBlock access token is missing or incorrect