Hedera blocks API

The blocks API from Hedera — 2 operation(s) for blocks.

OpenAPI Specification

hedera-blocks-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Mirror Node REST accounts blocks API
  version: 0.156.0
  license:
    name: Apache-2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
  description: 'The REST API offers the ability to query transactions and entity information from a mirror node.


    Base url: [/api/v1](/api/v1)


    OpenAPI Spec: [/api/v1/docs/openapi.yml](/api/v1/docs/openapi.yml)'
  contact:
    name: Mirror Node Team
    email: mirrornode@hedera.com
    url: https://github.com/hiero-ledger/hiero-mirror-node
servers:
- description: The current REST API server
  url: ''
- description: The production REST API servers
  url: '{scheme}://{network}.mirrornode.hedera.com'
  variables:
    scheme:
      default: https
      description: The URI scheme
      enum:
      - http
      - https
    network:
      default: testnet
      description: The Hedera network in use
      enum:
      - mainnet-public
      - mainnet
      - previewnet
      - testnet
tags:
- name: blocks
paths:
  /api/v1/blocks:
    get:
      summary: List blocks
      description: Returns a list of blocks on the network.
      operationId: getBlocks
      parameters:
      - $ref: '#/components/parameters/blockNumberQueryParam'
      - $ref: '#/components/parameters/limitQueryParam'
      - $ref: '#/components/parameters/orderQueryParamDesc'
      - $ref: '#/components/parameters/timestampQueryParam'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BlocksResponse'
        '400':
          $ref: '#/components/responses/InvalidParameterError'
      tags:
      - blocks
  /api/v1/blocks/{hashOrNumber}:
    get:
      summary: Get block by hash or number
      description: Returns the block information by given hash or number.
      operationId: getBlock
      parameters:
      - $ref: '#/components/parameters/hashOrNumberPathParam'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Block'
        '400':
          $ref: '#/components/responses/InvalidParameterError'
        '404':
          $ref: '#/components/responses/NotFoundError'
      tags:
      - blocks
components:
  schemas:
    Links:
      type: object
      properties:
        next:
          example: null
          type:
          - string
          - 'null'
    Block:
      type: object
      properties:
        count:
          type: integer
          minimum: 0
        gas_used:
          type:
          - integer
          - 'null'
          minimum: 0
          format: int64
        hapi_version:
          type:
          - string
          - 'null'
        hash:
          type: string
        logs_bloom:
          description: A hex encoded 256-byte array with 0x prefix
          type:
          - string
          - 'null'
          pattern: ^0x[0-9a-fA-F]{512}$
        name:
          type: string
        number:
          type: integer
          minimum: 0
        previous_hash:
          type: string
        size:
          type:
          - integer
          - 'null'
        timestamp:
          $ref: '#/components/schemas/TimestampRange'
      example:
        count: 3
        gas_used: 300000
        hapi_version: 0.11.0
        hash: '0x3c08bbbee74d287b1dcd3f0ca6d1d2cb92c90883c4acf9747de9f3f3162ad25b999fc7e86699f60f2a3fb3ed9a646c6b'
        logs_bloom: '0x00000020002000001000000000000000000000000000000000000000000010000000000004000000000000000000000000108000000000000000000080000000000004000000000000000000000000880000000000000000000101000000000000000000000000000000000000008000000000000400000080000000000001000000000000000000000000000000000000000000002000000000100000100000200000040000100000001000000000000000000000000000000001001000004000000000000000000001000000000000000000100000000000100000000000000000000000000000000000000000000000080000100800000000000000120080'
        name: 2022-05-03T06_46_26.060890949Z.rcd
        number: 77
        previous_hash: '0xf7d6481f659c866c35391ee230c374f163642ebf13a5e604e04a95a9ca48a298dc2dfa10f51bcbaab8ae23bc6d662a0b'
        size: 8192
        timestamp:
          from: '1651560386.060890949'
          to: '1651560386.661997287'
    TimestampRange:
      type: object
      description: A timestamp range an entity is valid for
      properties:
        from:
          allOf:
          - $ref: '#/components/schemas/Timestamp'
          - description: The inclusive from timestamp in seconds
        to:
          allOf:
          - $ref: '#/components/schemas/TimestampNullable'
          - description: The exclusive to timestamp in seconds
    TimestampNullable:
      description: A Unix timestamp in seconds.nanoseconds format
      type:
      - string
      - 'null'
      example: '1586567700.453054000'
      pattern: ^\d{1,10}(\.\d{1,9})?$
    Error:
      type: object
      properties:
        _status:
          type: object
          properties:
            messages:
              type: array
              items:
                type: object
                properties:
                  data:
                    description: Error message in hexadecimal
                    example: '0x3000'
                    format: binary
                    pattern: ^0x[0-9a-fA-F]+$
                    type:
                    - string
                    - 'null'
                  detail:
                    description: Detailed error message
                    example: Generic detailed error message
                    type:
                    - string
                    - 'null'
                  message:
                    description: Error message
                    example: Generic error message
                    type: string
    Blocks:
      type: array
      items:
        $ref: '#/components/schemas/Block'
    Timestamp:
      description: A Unix timestamp in seconds.nanoseconds format
      type: string
      example: '1586567700.453054000'
      pattern: ^\d{1,10}(\.\d{1,9})?$
    BlocksResponse:
      type: object
      properties:
        blocks:
          $ref: '#/components/schemas/Blocks'
        links:
          $ref: '#/components/schemas/Links'
  responses:
    InvalidParameterError:
      description: Invalid parameter
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            _status:
              messages:
              - message: 'Invalid parameter: account.id'
              - message: Invalid Transaction id. Please use \shard.realm.num-sss-nnn\ format where sss are seconds and nnn are nanoseconds
    NotFoundError:
      description: Not Found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            _status:
              messages:
              - message: Not found
  parameters:
    orderQueryParamDesc:
      name: order
      in: query
      description: The order in which items are listed
      example: asc
      schema:
        enum:
        - asc
        - desc
        default: desc
    limitQueryParam:
      name: limit
      in: query
      description: The maximum number of items to return
      example: 2
      schema:
        format: int32
        type: integer
        default: 25
        minimum: 1
        maximum: 100
    hashOrNumberPathParam:
      name: hashOrNumber
      in: path
      required: true
      description: Accepts both eth and hedera hash format or block number
      schema:
        pattern: ^(\d{1,10}|(0x)?([A-Fa-f0-9]{64}|[A-Fa-f0-9]{96}))$
        type: string
    blockNumberQueryParam:
      name: block.number
      in: query
      description: The block's number
      examples:
        noValue:
          summary: --
          value: ''
        noOperator:
          summary: Example of block.number equals with no operator
          value: 1
        eqOperator:
          summary: Example of block.number equals operator
          value: eq:2
        gtOperator:
          summary: Example of block.number greater than operator
          value: gt:3
        gteOperator:
          summary: Example of block.number greater than or equals operator
          value: gte:4
        ltOperator:
          summary: Example of block.number less than operator
          value: lt:5
        lteOperator:
          summary: Example of block.number less than or equals operator
          value: lte:6
      schema:
        type: string
        pattern: ^((eq|gt|gte|lt|lte):)?\d{1,19}$
    timestampQueryParam:
      description: The consensus timestamp as a Unix timestamp in seconds.nanoseconds format with an optional comparison operator. See [unixtimestamp.com](https://www.unixtimestamp.com/) for a simple way to convert a date to the 'seconds' part of the Unix time.
      name: timestamp
      in: query
      explode: true
      examples:
        noValue:
          summary: --
          value: ''
        secondsNoOperator:
          summary: Example of seconds equals with no operator
          value: 1234567890
        timestampNoOperator:
          summary: Example of timestamp equals with no operator
          value: 1234567890
        secondsEqOperator:
          summary: Example of seconds equals with operator
          value: eq:1234567890
        timestampEqOperator:
          summary: Example of timestamp equals with operator
          value: eq:1234567890.000000200
        secondsNeOperator:
          summary: Example of seconds not equals operator
          value: ne:1234567890
        timestampNeOperator:
          summary: Example of timestamp not equals operator
          value: ne:1234567890.000000300
        secondsGtOperator:
          summary: Example of seconds greater than operator
          value: gt:1234567890
        timestampGtOperator:
          summary: Example of timestamp greater than operator
          value: gt:1234567890.000000400
        secondsGteOperator:
          summary: Example of seconds greater than or equals operator
          value: gte:1234567890
        timestampGteOperator:
          summary: Example of timestamp greater than or equals operator
          value: gte:1234567890.000000500
        secondsLtOperator:
          summary: Example of seconds less than operator
          value: lt:1234567890
        timestampLtOperator:
          summary: Example of timestamp less than operator
          value: lt:1234567890.000000600
        secondsLteOperator:
          summary: Example of seconds less than or equals operator
          value: lte:1234567890
        timestampLteOperator:
          summary: Example of timestamp less than or equals operator
          value: lte:1234567890.000000700
      schema:
        type: array
        items:
          type: string
          pattern: ^((eq|gt|gte|lt|lte|ne):)?\d{1,10}(\.\d{1,9})?$
externalDocs:
  description: REST API Docs
  url: https://docs.hedera.com/guides/docs/mirror-node-api/cryptocurrency-api