> ## Documentation Index
> Fetch the complete documentation index at: https://cosmos-docs-sync-security-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# blockchain

> Get block headers (max: 20) for minHeight <= height <= maxHeight.

Get block headers for minHeight <= height <= maxHeight.

At most 20 items will be returned.

Upon success, the `Cache-Control` header will be set with the default
maximum age.



## OpenAPI

````yaml /cometbft/latest/api-reference/rpc/openapi.yaml get /blockchain
openapi: 3.0.0
info:
  title: CometBFT RPC
  contact:
    name: CometBFT
    url: https://docs.cosmos.network/cometbft
  description: >
    CometBFT supports the following RPC protocols:


    * URI over HTTP

    * JSONRPC over HTTP

    * JSONRPC over websockets


    ## Configuration


    RPC can be configured by tuning parameters under `[rpc]` table in the

    `$CMTHOME/config/config.toml` file or by using the `--rpc.X` command-line

    flags.


    The default RPC listen address is `tcp://127.0.0.1:26657`.

    To set another address, set the `laddr` config parameter to desired value.

    CORS (Cross-Origin Resource Sharing) can be enabled by setting

    `cors_allowed_origins`, `cors_allowed_methods`, `cors_allowed_headers`

    config parameters.


    If testing using a local RPC node, under the `[rpc]`

    section change the `cors_allowed_origins` property, please add the URL of

    the site where this OpenAPI document is running, for example:

      `cors_allowed_origins = ["http://localhost:8088"]`

    or if testing from the official documentation site:

      `cors_allowed_origins = ["https://docs.cosmos.network"]`

    ## Arguments


    Arguments which expect strings or byte arrays may be passed as quoted

    strings, like `"abc"` or as `0x`-prefixed strings, like `0x616263`.


    ## URI/HTTP


    A REST like interface.

        curl localhost:26657/block?height=5

    ## JSONRPC/HTTP


    JSONRPC requests can be POST'd to the root RPC endpoint via HTTP.

        curl --header "Content-Type: application/json" --request POST --data '{"method": "block", "params": ["5"], "id": 1}' localhost:26657

    ## JSONRPC/websockets


    JSONRPC requests can be also made via websocket.

    The websocket endpoint is at `/websocket`, e.g. `localhost:26657/websocket`.

    Asynchronous RPC functions like event `subscribe` and `unsubscribe` are

    only available via websockets.


    For example using the [websocat](https://github.com/vi/websocat) tool, you
    can subscribe for 'NewBlock` events

    with the following command:

        echo '{ "jsonrpc": "2.0","method": "subscribe","id": 0,"params": {"query": "tm.event='"'NewBlock'"'"} }' | websocat -n -t ws://127.0.0.1:26657/websocket
  version: v0.38.x
  license:
    name: Apache 2.0
    url: https://github.com/cometbft/cometbft/blob/v0.38.x/LICENSE
servers:
  - url: https://rpc.cosmos.directory/cosmoshub
    description: Interact with the CometBFT RPC from a public node in the Cosmos registry
  - url: http://localhost:26657
    description: Interact with CometBFT RPC node running locally
security: []
tags:
  - name: Info
    description: Informations about the node APIs
  - name: Tx
    description: Transactions broadcast APIs
  - name: ABCI
    description: ABCI APIs
  - name: Evidence
    description: Evidence APIs
  - name: Unsafe
    description: Unsafe APIs
paths:
  /blockchain:
    get:
      tags:
        - Info
      summary: blockchain
      description: |-
        Get block headers (max: 20) for minHeight <= height <= maxHeight.

        Get block headers for minHeight <= height <= maxHeight.

        At most 20 items will be returned.

        Upon success, the `Cache-Control` header will be set with the default
        maximum age.
      operationId: blockchain
      parameters:
        - in: query
          name: minHeight
          description: Minimum block height to return
          schema:
            type: integer
            example: 1
        - in: query
          name: maxHeight
          description: Maximum block height to return
          schema:
            type: integer
            example: 2
      responses:
        '200':
          description: Block headers, returned in descending order (highest first).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BlockchainResponse'
        '500':
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    BlockchainResponse:
      description: Blockchain info
      allOf:
        - $ref: '#/components/schemas/JSONRPC'
        - type: object
          properties:
            result:
              $ref: '#/components/schemas/Blockchain'
    ErrorResponse:
      description: Error Response
      allOf:
        - $ref: '#/components/schemas/JSONRPC'
        - type: object
          properties:
            error:
              type: string
              example: Description of failure
    JSONRPC:
      type: object
      properties:
        id:
          type: integer
          example: 0
        jsonrpc:
          type: string
          example: '2.0'
    Blockchain:
      type: object
      required:
        - last_height
        - block_metas
      properties:
        last_height:
          type: string
          example: '1276718'
        block_metas:
          type: array
          items:
            $ref: '#/components/schemas/BlockMeta'
    BlockMeta:
      type: object
      properties:
        block_id:
          $ref: '#/components/schemas/BlockID'
        block_size:
          type: integer
          example: 1000000
        header:
          $ref: '#/components/schemas/BlockHeader'
        num_txs:
          type: string
          example: '54'
    BlockID:
      required:
        - hash
        - parts
      properties:
        hash:
          type: string
          example: 112BC173FD838FB68EB43476816CD7B4C6661B6884A9E357B417EE957E1CF8F7
        parts:
          required:
            - total
            - hash
          properties:
            total:
              type: integer
              example: 1
            hash:
              type: string
              example: 38D4B26B5B725C4F13571EFE022C030390E4C33C8CF6F88EDD142EA769642DBD
          type: object
    BlockHeader:
      required:
        - version
        - chain_id
        - height
        - time
        - last_block_id
        - last_commit_hash
        - data_hash
        - validators_hash
        - next_validators_hash
        - consensus_hash
        - app_hash
        - last_results_hash
        - evidence_hash
        - proposer_address
      properties:
        version:
          required:
            - block
            - app
          properties:
            block:
              type: string
              example: '10'
            app:
              type: string
              example: '0'
          type: object
        chain_id:
          type: string
          example: cosmoshub-2
        height:
          type: string
          example: '12'
        time:
          type: string
          example: '2019-04-22T17:01:51.701356223Z'
        last_block_id:
          $ref: '#/components/schemas/BlockID'
        last_commit_hash:
          type: string
          example: 21B9BC845AD2CB2C4193CDD17BFC506F1EBE5A7402E84AD96E64171287A34812
        data_hash:
          type: string
          example: 970886F99E77ED0D60DA8FCE0447C2676E59F2F77302B0C4AA10E1D02F18EF73
        validators_hash:
          type: string
          example: D658BFD100CA8025CFD3BECFE86194322731D387286FBD26E059115FD5F2BCA0
        next_validators_hash:
          type: string
          example: D658BFD100CA8025CFD3BECFE86194322731D387286FBD26E059115FD5F2BCA0
        consensus_hash:
          type: string
          example: 0F2908883A105C793B74495EB7D6DF2EEA479ED7FC9349206A65CB0F9987A0B8
        app_hash:
          type: string
          example: 223BF64D4A01074DC523A80E76B9BBC786C791FB0A1893AC5B14866356FCFD6C
        last_results_hash:
          type: string
          example: ''
        evidence_hash:
          type: string
          example: ''
        proposer_address:
          type: string
          example: D540AB022088612AC74B287D076DBFBC4A377A2E
      type: object

````