> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sonarx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Filter Blocks

> Get multiple blocks within a specified range



## OpenAPI

````yaml POST /api/v1/customer/{chain}/blocks/filter
openapi: 3.1.0
info:
  title: SonarX EVM API - Blocks
  description: >-
    Query block data, receipts, and transaction counts for EVM-compatible
    networks.
  version: 1.0.0
servers:
  - url: https://api-gateway.sonarx.com
    description: Production API
security:
  - apiKey: []
tags:
  - name: Blocks
    description: Query block data, receipts, and transaction counts
paths:
  /api/v1/customer/{chain}/blocks/filter:
    post:
      tags:
        - Blocks
      summary: Filter Blocks
      description: >-
        Get multiple blocks within a specified range. Use either block range
        (`from_block`/`to_block`) OR datetime range
        (`from_datetime`/`to_datetime`), not both. Block range cannot exceed 100
        blocks.
      operationId: filterBlocks
      parameters:
        - $ref: '#/components/parameters/ChainPath'
        - $ref: '#/components/parameters/Limit'
        - $ref: '#/components/parameters/Offset'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BlockFilterRequest'
            examples:
              byBlockRange:
                summary: Filter by block range
                value:
                  from_block: 81901160
                  to_block: 81901165
                  full_transactions: false
              byDatetimeRange:
                summary: Filter by datetime range
                value:
                  from_datetime: '2026-01-20T15:15:00Z'
                  to_datetime: '2026-01-20T15:18:00Z'
      responses:
        '200':
          description: Filtered blocks
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BlockFilterResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  parameters:
    ChainPath:
      name: chain
      in: path
      description: The blockchain network to query
      required: true
      schema:
        type: string
        enum:
          - polygon
        example: polygon
    Limit:
      name: limit
      in: query
      description: Maximum number of results (1-50)
      required: false
      schema:
        type: integer
        minimum: 1
        maximum: 50
        default: 10
    Offset:
      name: offset
      in: query
      description: Number of results to skip for pagination
      required: false
      schema:
        type: integer
        minimum: 0
        default: 0
  schemas:
    BlockFilterRequest:
      type: object
      description: >-
        Request body for filtering blocks. Validation rules: (1) Must provide
        either block range OR datetime range, not both and not neither. (2) When
        using block range, both from_block AND to_block are required. (3) When
        using datetime range, both from_datetime AND to_datetime are required.
        (4) to_block must be >= from_block. (5) to_datetime must be >=
        from_datetime. (6) Block range cannot exceed 100 blocks.
      properties:
        from_block:
          type: integer
          minimum: 0
          description: Start block number. Required if using block range.
        to_block:
          type: integer
          minimum: 0
          description: >-
            End block number. Required if using block range. Must be >=
            from_block and within 100 blocks of from_block.
        from_datetime:
          type: string
          format: date-time
          description: >-
            Start datetime (ISO 8601, timezone required, e.g.,
            2024-01-15T10:30:00Z or 2024-01-15T10:30:00+00:00). Required if
            using datetime range.
        to_datetime:
          type: string
          format: date-time
          description: >-
            End datetime (ISO 8601, timezone required, e.g.,
            2024-01-15T10:30:00Z or 2024-01-15T10:30:00+00:00). Required if
            using datetime range. Must be >= from_datetime.
        full_transactions:
          type: boolean
          default: false
          description: Include full transaction objects
    BlockFilterResponse:
      type: object
      properties:
        from_block:
          type: integer
          nullable: true
        to_block:
          type: integer
          nullable: true
        from_datetime:
          type: string
          nullable: true
        to_datetime:
          type: string
          nullable: true
        offset:
          type: integer
        limit:
          type: integer
        result:
          type: array
          items:
            $ref: '#/components/schemas/Block'
        count:
          type: integer
      example:
        from_block: 81901160
        to_block: 81901165
        from_datetime: null
        to_datetime: null
        offset: 0
        limit: 10
        result:
          - block_number: 81901165
            timestamp: 1768922302
            datetime: '2026-01-20T15:18:22'
            block_hash: '0x70977f71168a51813978584b23cccd0fa86cdc1239ab403feafc68e85733af1a'
            block_parent_hash: '0x8ee5ee7b7256f12f985f8dcdc2a3ca26a494be30ca6ba379cba2a5a06c6cd311'
            version: 0
            transactions_root: '0xb11abe9386303f977bbfa935f4b2c4924a45b41095c24b207828c12e2cb7f058'
            state_root: '0x7850f2b1d88f135ca3b7506add74ab738c168748ce825543d43d49ad2471c584'
            receipts_root: '0x74dd7cda82d48726b16c25560a00d11d37e525e35c060b6958e7350a53b47dd1'
            miner: '0x0000000000000000000000000000000000000000'
            size: 188062
            gas_limit: 65000000
            gas_used: 39500751
            transaction_count: 176
            base_fee_per_gas: 600795160350
          - block_number: 81901164
            timestamp: 1768922300
            datetime: '2026-01-20T15:18:20'
            block_hash: '0x8ee5ee7b7256f12f985f8dcdc2a3ca26a494be30ca6ba379cba2a5a06c6cd311'
            block_parent_hash: '0x33031d51e8f973d2465ba1fd1245e9db6fe07561c55d6288161fb7b077e6e769'
            version: 0
            transactions_root: '0x799caf39ec0ba4cfd7d9eead83ffd32df1f863022917a94df55a3e629a9410f9'
            state_root: '0xe45b0784f2b8a452725bf82ef9a4c722e54a0ffb19a2696ab04e88a2a16fba19'
            receipts_root: '0x29e8ad9db7df634df6c7b9bdb2dda16090086793e71dfa81252070caab69b8f8'
            miner: '0x0000000000000000000000000000000000000000'
            size: 175432
            gas_limit: 65000000
            gas_used: 34100066
            transaction_count: 152
            base_fee_per_gas: 602611448639
        count: 6
    Block:
      type: object
      properties:
        block_number:
          type: integer
          description: The block number
        timestamp:
          type: integer
          description: Unix timestamp of the block
        datetime:
          type: string
          format: date-time
          description: ISO 8601 formatted datetime
        block_hash:
          type: string
          description: Hash of the block
        block_parent_hash:
          type: string
          description: Hash of the parent block
        version:
          type: integer
          description: Block version
        logs_bloom:
          type: string
          description: Bloom filter for the logs
        transactions_root:
          type: string
          description: Root hash of the transactions trie
        state_root:
          type: string
          description: Root hash of the state trie
        receipts_root:
          type: string
          description: Root hash of the receipts trie
        miner:
          type: string
          description: Address of the block miner/validator
        extra_data:
          type: string
          description: Extra data included in the block
        size:
          type: integer
          description: Size of the block in bytes
        gas_limit:
          type: integer
          description: Maximum gas allowed in this block
        gas_used:
          type: integer
          description: Total gas used by all transactions
        transaction_count:
          type: integer
          description: Number of transactions in the block
        base_fee_per_gas:
          type: integer
          description: Base fee per gas in wei
      example:
        block_number: 81901165
        timestamp: 1768922302
        datetime: '2026-01-20T15:18:22'
        block_hash: '0x70977f71168a51813978584b23cccd0fa86cdc1239ab403feafc68e85733af1a'
        block_parent_hash: '0x8ee5ee7b7256f12f985f8dcdc2a3ca26a494be30ca6ba379cba2a5a06c6cd311'
        version: 0
        transactions_root: '0xb11abe9386303f977bbfa935f4b2c4924a45b41095c24b207828c12e2cb7f058'
        state_root: '0x7850f2b1d88f135ca3b7506add74ab738c168748ce825543d43d49ad2471c584'
        receipts_root: '0x74dd7cda82d48726b16c25560a00d11d37e525e35c060b6958e7350a53b47dd1'
        miner: '0x0000000000000000000000000000000000000000'
        size: 188062
        gas_limit: 65000000
        gas_used: 39500751
        transaction_count: 176
        base_fee_per_gas: 600795160350
    ErrorResponse:
      type: object
      properties:
        detail:
          type: string
          description: Error message
      required:
        - detail
  responses:
    BadRequest:
      description: Bad Request - Invalid parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missingBlockNumber:
              summary: Missing block number
              value:
                detail: block_number is required
            mixedRangeParams:
              summary: Mixed block and datetime parameters
              value:
                detail: >-
                  Cannot mix block and datetime parameters. Use either
                  from_block/to_block or from_datetime/to_datetime, not both
            missingRangeParams:
              summary: No range parameters provided
              value:
                detail: >-
                  Either block range (from_block/to_block) or datetime range
                  (from_datetime/to_datetime) must be provided
            incompleteBlockRange:
              summary: Incomplete block range
              value:
                detail: Both from_block and to_block must be provided together
            incompleteDatetimeRange:
              summary: Incomplete datetime range
              value:
                detail: Both from_datetime and to_datetime must be provided together
            invalidBlockOrder:
              summary: Invalid block range order
              value:
                detail: to_block must be >= from_block
            blockRangeTooLarge:
              summary: Block range exceeds limit
              value:
                detail: Block range cannot exceed 100 blocks
    Unauthorized:
      description: Unauthorized - Invalid or missing API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            detail: Invalid API key
    InternalError:
      description: Internal Server Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            detail: Internal server error
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: apikey
      description: API key for authentication. Contact SonarX to obtain your API key.

````