> ## 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 Transaction by Block

> Get a transaction by block number or hash and transaction index



## OpenAPI

````yaml GET /api/v1/customer/{chain}/blocks/transaction
openapi: 3.1.0
info:
  title: SonarX EVM API - Transactions
  description: >-
    Query transaction data, receipts, and fee history for EVM-compatible
    networks.
  version: 1.0.0
servers:
  - url: https://api-gateway.sonarx.com
    description: Production API
security:
  - apiKey: []
tags:
  - name: Transactions
    description: Query transaction data, receipts, and fee history
paths:
  /api/v1/customer/{chain}/blocks/transaction:
    get:
      tags:
        - Transactions
      summary: Get Transaction by Block
      description: Get a transaction by block number and transaction index.
      operationId: getTransactionByBlock
      parameters:
        - $ref: '#/components/parameters/ChainPath'
        - name: block_number
          in: query
          description: Block number to query (>= 0)
          required: true
          schema:
            type: integer
            minimum: 0
            example: 81901165
        - name: transaction_index
          in: query
          description: Transaction position in block (0-indexed)
          required: true
          schema:
            type: integer
            minimum: 0
            example: 0
      responses:
        '200':
          description: Transaction data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Transaction'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '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
  schemas:
    Transaction:
      type: object
      properties:
        block_number:
          type: integer
          description: Block number containing this transaction
        timestamp:
          type: integer
          description: Unix timestamp of the block
        datetime:
          type: string
          format: date-time
          description: ISO 8601 formatted datetime
        transaction_hash:
          type: string
          description: Hash of the transaction
        transaction_index:
          type: integer
          description: Position of the transaction in the block
        version:
          type: integer
          description: Transaction version
        from_address:
          type: string
          description: Sender address
        to_address:
          type: string
          nullable: true
          description: Recipient address
        value:
          type: number
          description: Value transferred in native token
        usd_value:
          type: number
          description: USD value of the transfer
        price:
          type: number
          description: Native token price in USD
        transaction_fee:
          type: number
          description: Transaction fee in native token
        usd_transaction_fee:
          type: number
          description: Transaction fee in USD
        gas_price:
          type: number
          description: Gas price in native token
        gas_price_gwei:
          type: number
          description: Gas price in Gwei
        effective_gas_price:
          type: number
          description: Effective gas price
        effective_gas_price_gwei:
          type: number
          description: Effective gas price in Gwei
        max_fee_per_gas:
          type: number
          nullable: true
          description: Maximum fee per gas (EIP-1559)
        max_fee_per_gas_gwei:
          type: number
          nullable: true
        max_priority_fee_per_gas:
          type: number
          nullable: true
          description: Maximum priority fee (EIP-1559)
        max_priority_fee_per_gas_gwei:
          type: number
          nullable: true
        gas_limit:
          type: integer
          description: Maximum gas allowed
        gas_used:
          type: integer
          description: Actual gas used
        gas_used_pct:
          type: number
          description: Percentage of gas limit used
        cumulative_gas_used:
          type: integer
          description: Total gas used up to this transaction
        input:
          type: string
          description: Transaction input data
        transaction_type:
          type: integer
          description: Transaction type (0=legacy, 1=access list, 2=EIP-1559)
        contract_address:
          type: string
          nullable: true
          description: Contract address created
        status:
          type: boolean
          description: Transaction success status
        source_value:
          type: string
          description: Raw value in wei
        source_gas_price:
          type: string
        source_effective_gas_price:
          type: string
        source_max_fee_per_gas:
          type: string
          nullable: true
        source_max_priority_fee_per_gas:
          type: string
          nullable: true
      example:
        block_number: 81911103
        timestamp: 1768942178
        datetime: '2026-01-20T20:49:38'
        transaction_hash: '0x0063079708b5fab44762765a01c17ab2754ebc15cb9ecd0e14fcbbd520452c27'
        transaction_index: 80
        version: 0
        from_address: '0xb63c1246a11edc1e784c39ab95295e4180c5071b'
        to_address: '0x9ead30c8518a19f0b493eea1bd5af8fcc5fd4ba2'
        value: 1.e-7
        usd_value: 1.30889e-8
        price: 0.130889
        transaction_fee: 0.000762618316404
        usd_transaction_fee: 0.00009981834881580316
        gas_price: 3.6315157924e-8
        gas_price_gwei: 36.315157924
        effective_gas_price: 3.6315157924e-8
        effective_gas_price_gwei: 36.315157924
        max_fee_per_gas: null
        max_fee_per_gas_gwei: null
        max_priority_fee_per_gas: null
        max_priority_fee_per_gas_gwei: null
        gas_limit: 21200
        gas_used: 21000
        gas_used_pct: 0.9905660377358491
        cumulative_gas_used: 9824334
        input: 0x
        transaction_type: 0
        contract_address: null
        status: true
        source_value: '100000000000'
        source_gas_price: '36315157924'
        source_effective_gas_price: '36315157924'
        source_max_fee_per_gas: null
        source_max_priority_fee_per_gas: null
    ErrorResponse:
      type: object
      properties:
        detail:
          type: string
      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
            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
    NotFound:
      description: Not Found - Resource does not exist
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            detail: Transaction not found
    InternalError:
      description: Internal Server Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            detail: An unexpected error occurred
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: apikey
      description: API key for authentication

````