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

# Get profit and loss history for an obligation

> Returns transaction and periodic mark-to-market PnL for the current obligation. Snapshots are hourly for positions younger than 32 days and daily otherwise, timestamped at observation time. Periodic points that cannot be valued are omitted. Optional start (inclusive) and end (exclusive) filter the history; totals always describe the current position. For xSOL pairs, useStakeRate uses stake-rate pricing.



## OpenAPI

````yaml /kamino-api.json get /v2/kamino-market/{marketPubkey}/obligations/{obligationPubkey}/pnl/history
openapi: 3.1.0
info:
  version: 1.0.0
  title: Kamino Public API
  description: >
    The Kamino API provides a comprehensive way to interact with Kamino without
    reading directly from the blockchain.


    The API also provides the ability to fetch data that might not be available
    from just reading the chain.


    The API is rate-limited for unauthenticated users. If you feel you need to
    make more requests or run into rate-limit issues, please reach out.
servers:
  - url: https://api.kamino.finance
security: []
paths:
  /v2/kamino-market/{marketPubkey}/obligations/{obligationPubkey}/pnl/history:
    get:
      tags:
        - Kamino Lend User Loans
      summary: Get profit and loss history for an obligation
      description: >-
        Returns transaction and periodic mark-to-market PnL for the current
        obligation. Snapshots are hourly for positions younger than 32 days and
        daily otherwise, timestamped at observation time. Periodic points that
        cannot be valued are omitted. Optional start (inclusive) and end
        (exclusive) filter the history; totals always describe the current
        position. For xSOL pairs, useStakeRate uses stake-rate pricing.
      parameters:
        - schema:
            allOf:
              - $ref: '#/components/schemas/AddressBase58'
              - description: Kamino Lend market public key
                example: 7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF
          required: true
          description: Kamino Lend market public key
          name: marketPubkey
          in: path
        - schema:
            allOf:
              - $ref: '#/components/schemas/AddressBase58'
              - description: Kamino Lend obligation public key
                example: 63QrAB1okxCc4FpsgcKYHjYTp1ua8ch6mLReyKRdc22o
          required: true
          description: Kamino Lend obligation public key
          name: obligationPubkey
          in: path
        - schema:
            type: string
            enum:
              - mainnet-beta
              - devnet
              - localnet
            default: mainnet-beta
            description: Solana cluster environment
            example: mainnet-beta
          required: false
          description: Solana cluster environment
          name: env
          in: query
        - schema:
            type: string
            default: KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD
            description: KLend program ID
            example: KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD
          required: false
          description: KLend program ID
          name: programId
          in: query
        - schema:
            type: string
            enum:
              - 'true'
              - 'false'
            default: 'false'
            description: For xSOL pairs, calculate the PnL using the stake rate
            example: 'true'
          required: false
          description: For xSOL pairs, calculate the PnL using the stake rate
          name: useStakeRate
          in: query
        - schema:
            anyOf:
              - type: string
              - type: number
            description: Date input (ISO 8601 string or epoch in ms)
            examples:
              - '2024-01-01T00:00:00.000Z'
              - 1704067200000
            example: 2020-01-01T00:00Z
          required: false
          description: Date input (ISO 8601 string or epoch in ms)
          name: start
          in: query
        - schema:
            anyOf:
              - type: string
              - type: number
            description: Date input (ISO 8601 string or epoch in ms)
            examples:
              - '2024-01-01T00:00:00.000Z'
              - 1704067200000
            example: 2020-02-01T00:00Z
          required: false
          description: Date input (ISO 8601 string or epoch in ms)
          name: end
          in: query
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KlendPnlHistoryResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: High-level error message describing the failure
                    example: Invalid query params
                  details:
                    type: array
                    items:
                      type: object
                      additionalProperties: {}
                    description: >-
                      Detailed validation issues (present only for validation
                      errors)
                required:
                  - error
                description: Bad request response (400)
                example:
                  error: Invalid query request
                  details:
                    - code: invalid_union
                      errors:
                        - - code: custom
                            path: []
                            message: Invalid date string
                        - - expected: number
                            code: invalid_type
                            path: []
                            message: 'Invalid input: expected number, received string'
                      path:
                        - start
                      message: Invalid input
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                type: object
                properties:
                  metadata:
                    type: string
                    description: Error message describing why it was not found
                    example: Account could not be found
                required:
                  - metadata
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: >-
                      Error message describing why the request could not be
                      processed
                    example: The requested calculation is not supported for this asset
                required:
                  - error
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                required:
                  - error
components:
  schemas:
    AddressBase58:
      type: string
      description: Valid base58-encoded address
      example: VEG1EMtttdHunMbSza8uoms1R18VXmYSph2bBpHcSJd
    KlendPnlHistoryResponse:
      type: object
      properties:
        history:
          type: array
          items:
            type: object
            properties:
              timestamp:
                type: number
                description: >-
                  Timestamp in milliseconds since Unix epoch; events sharing one
                  are served as their final state
              type:
                type: string
                enum:
                  - deposit
                  - withdraw
                  - borrow
                  - repay
                  - liquidate
                  - create
                  - repay-and-withdraw
                  - deposit-and-withdraw
                  - rollover-fixed-term-borrow
                  - mark-to-market
                description: >-
                  Cash flow type, or mark-to-market for a periodic or current
                  valuation
              pnl:
                type: object
                properties:
                  usd:
                    $ref: '#/components/schemas/Decimal'
                  sol:
                    $ref: '#/components/schemas/Decimal'
                required:
                  - usd
                  - sol
              investment:
                type: object
                properties:
                  usd:
                    $ref: '#/components/schemas/Decimal'
                  sol:
                    $ref: '#/components/schemas/Decimal'
                required:
                  - usd
                  - sol
                description: Net capital invested at this point
              positionValue:
                type: object
                properties:
                  usd:
                    $ref: '#/components/schemas/Decimal'
                  sol:
                    $ref: '#/components/schemas/Decimal'
                required:
                  - usd
                  - sol
            required:
              - timestamp
              - type
              - pnl
              - investment
              - positionValue
        totalPnl:
          type: object
          properties:
            usd:
              $ref: '#/components/schemas/Decimal'
            sol:
              $ref: '#/components/schemas/Decimal'
          required:
            - usd
            - sol
          description: Current PnL; start and end do not affect it
        invested:
          type: object
          properties:
            usd:
              $ref: '#/components/schemas/Decimal'
            sol:
              $ref: '#/components/schemas/Decimal'
          required:
            - usd
            - sol
          description: Current net capital invested; start and end do not affect it
        truncatedHistory:
          type: boolean
          description: >-
            True when the computation cap dropped older transactions or periodic
            points
        accountingVersion:
          type: number
          enum:
            - 2
          description: PnL accounting version
        status:
          type: string
          enum:
            - complete
            - partial
            - unavailable
          description: Accounting completeness
        reasons:
          type: array
          items:
            type: string
          description: Reasons for partial or unavailable accounting
      required:
        - history
        - totalPnl
        - invested
        - truncatedHistory
        - accountingVersion
        - status
        - reasons
    Error:
      type: object
      properties:
        error:
          type: string
          description: Error message for internal server failure
          example: An internal error occurred
      required:
        - error
      description: Internal server error response (500)
      example:
        error: An internal error occurred
    Decimal:
      type: string
      description: Decimal value represented as string
      example: '1234.56789'

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.