> ## 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.

# Get Latest Block

> Get the latest block number for a chain



## OpenAPI

````yaml GET /api/v1/customer/{chain}/blocks/latest
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/latest:
    get:
      tags:
        - Blocks
      summary: Get Latest Block
      description: Get the latest block number for a chain.
      operationId: getLatestBlock
      parameters:
        - $ref: '#/components/parameters/ChainPath'
      responses:
        '200':
          description: Latest block number
          content:
            application/json:
              schema:
                type: object
                properties:
                  block_number:
                    type: integer
                    description: The latest block number on the chain
              example:
                block_number: 81901165
        '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
  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
  schemas:
    ErrorResponse:
      type: object
      properties:
        detail:
          type: string
          description: Error message
      required:
        - detail
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: apikey
      description: API key for authentication. Contact SonarX to obtain your API key.

````