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

# Get wallet PnL

> This endpoint returns the Profit and Loss (PnL) details of a web3 wallet.
This includes Unrealized PnL, Realized PnL, Net Invested amounts and filters for asset categories like Non Fungible Tokens (NFTs).
It uses the FIFO (First In, First Out) standard for calculations, providing accurate insights into wallet performance.
Ideal for tracking and analyzing financial outcomes of wallet activity.

The very first request for a wallet might result in a 503 which should be retried later.
Wallets with over 1 million transactions are not supported.




## OpenAPI

````yaml /openapi-v1.yaml get /v1/wallets/{address}/pnl
openapi: 3.0.3
info:
  version: 1.0.0
  title: REST API
  description: REST-like API provides access to rich Zerion ecosystem.
  contact:
    name: Zerion API
    url: https://developers.zerion.io/
    email: api@zerion.io
servers:
  - description: Production API
    url: https://api.zerion.io
security:
  - APIKeyBasicAuth: []
tags:
  - name: wallets
    description: >-
      Operations related to wallets, such as portfolio charts, positions, and
      transactions.
  - name: wallet sets
    description: >-
      Operations on a wallet set — aggregated portfolio data across at most one
      EVM address and one Solana address queried together.
  - name: fungibles
    description: >-
      Operations related to fungible assets, such as list them all, search or
      get by ID.
  - name: chains
    description: Operations related to chains, such as list all chains.
  - name: swap
    description: Operations related to swapping and bridging assets.
  - name: gas
    description: Operations related to gas.
  - name: nfts
    description: >-
      Operations related to non fungible assets, such list them, search or get
      by ID.
  - name: dapps
    description: >-
      Operations related to decentralized applications, such as list them all,
      search or get by ID.
  - name: subscriptions to transactions
    description: Operations related to subscriptions to transactions.
paths:
  /v1/wallets/{address}/pnl:
    get:
      tags:
        - wallets
      summary: Get wallet PnL
      description: >
        This endpoint returns the Profit and Loss (PnL) details of a web3
        wallet.

        This includes Unrealized PnL, Realized PnL, Net Invested amounts and
        filters for asset categories like Non Fungible Tokens (NFTs).

        It uses the FIFO (First In, First Out) standard for calculations,
        providing accurate insights into wallet performance.

        Ideal for tracking and analyzing financial outcomes of wallet activity.


        The very first request for a wallet might result in a 503 which should
        be retried later.

        Wallets with over 1 million transactions are not supported.
      operationId: getWalletPNL
      parameters:
        - $ref: '#/components/parameters/Currency'
        - $ref: '#/components/parameters/WalletAddress'
        - name: filter[chain_ids]
          in: query
          style: form
          explode: false
          description: Calculate PnL only for specified chains (comma-separated list).
          schema:
            type: array
            example:
              - ethereum
              - polygon
            maxItems: 25
            items:
              type: string
        - name: filter[fungible_ids]
          in: query
          style: form
          explode: false
          description: >
            Account only for PnL related to given fungible assets
            (comma-separated list). Maximum of 100 fungible IDs allowed.


            When filtering by fungible_ids or fungible_implementations, assets
            without available prices are automatically excluded from
            calculations instead of causing an error. Excluded assets are
            returned in the response metadata for transparency.
          schema:
            type: array
            maxItems: 100
            items:
              type: string
              maxLength: 44
        - name: filter[fungible_implementations]
          in: query
          style: form
          explode: false
          description: >
            Account only for PnL related to given fungible asset implementations
            (comma-separated list of chain:address pairs). Maximum of 100
            implementations allowed.

            example:
            "base:0xae16c445d8a4082cecb49a9465e4dd5499df947d,ethereum:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"


            When filtering by fungible_ids or fungible_implementations, assets
            without available prices are automatically excluded from
            calculations instead of causing an error. Excluded assets are
            returned in the response metadata for transparency.
          schema:
            type: array
            maxItems: 100
            items:
              type: string
        - name: since
          in: query
          required: false
          description: >-
            Only account sales since the given date.

            A unix timestamp in milliseconds.

            **Note:** PnL is pre-computed at standard marks (`now`, `1 day ago`,
            `1 week ago`, `1 month ago`, `1 year ago`, `beginning of the year`).
            Other values are supported only if fewer than 3,000 transactions sit
            between your timestamp and the nearest mark — otherwise the request
            errors out.
          schema:
            type: string
            example: '1688842525735'
            minLength: 13
            maxLength: 13
        - name: till
          in: query
          required: false
          description: >-
            Only account sales till the given date.

            A unix timestamp in milliseconds.

            **Note:** PnL is pre-computed at standard marks (`now`, `1 day ago`,
            `1 week ago`, `1 month ago`, `1 year ago`, `beginning of the year`).
            Other values are supported only if fewer than 3,000 transactions sit
            between your timestamp and the nearest mark — otherwise the request
            errors out.
          schema:
            type: string
            example: '1688842525735'
            minLength: 13
            maxLength: 13
      responses:
        '200':
          $ref: '#/components/responses/PNLResponse'
        '400':
          $ref: '#/components/responses/MalformedParameters'
        '401':
          $ref: '#/components/responses/UnauthenticatedError'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '503':
          $ref: '#/components/responses/RetryAfter'
components:
  parameters:
    Currency:
      name: currency
      in: query
      required: false
      description: Denominated currency value of returned prices
      schema:
        type: string
        default: usd
        enum:
          - eth
          - btc
          - usd
          - eur
          - krw
          - rub
          - gbp
          - aud
          - cad
          - inr
          - jpy
          - nzd
          - try
          - zar
          - cny
          - chf
    WalletAddress:
      name: address
      in: path
      required: true
      description: >-
        The web3 wallet address. Must be a valid EVM or Solana address. Returns
        400 if the address is not tracked by Zerion.
      example: '0x42b9df65b219b3dd36ff330a4dd8f327a6ada990'
      schema:
        $ref: '#/components/schemas/WalletAddress'
  responses:
    PNLResponse:
      description: Response for requested wallet's pnl
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/WalletPNLResponse'
    MalformedParameters:
      description: Parameters are malformed
      content:
        application/json:
          schema:
            type: object
            properties:
              errors:
                type: array
                items:
                  type: object
                  properties:
                    title:
                      type: string
                      description: Error short title
                      example: Parameter is malformed
                    detail:
                      type: string
                      description: Long description of the error
                      example: Some validation errors will be described here
    UnauthenticatedError:
      description: Unathenticated request
      content:
        application/json:
          schema:
            type: object
            properties:
              errors:
                type: array
                items:
                  type: object
                  properties:
                    title:
                      type: string
                      description: Error short title
                      example: Unauthorized Error
                    detail:
                      type: string
                      description: Long description of the error
                      example: >-
                        The API key is invalid, please, make sure that you are
                        using a valid key
    TooManyRequests:
      description: Too many requests error
      content:
        application/json:
          schema:
            type: object
            properties:
              errors:
                type: array
                items:
                  type: object
                  properties:
                    title:
                      type: string
                      description: Error short title
                      example: Too many requests
                    detail:
                      type: string
                      description: Long description of the error
                      example: Your request had been throttled
    RetryAfter:
      description: Service is temporarily unavailable
      headers:
        Retry-After:
          description: >
            Indicates how long the client should wait before making a follow-up
            request.
          schema:
            type: integer
            example: 10
            description: Number of seconds to wait.
      content:
        application/json:
          schema:
            type: object
            properties:
              errors:
                type: array
                items:
                  type: object
                  properties:
                    title:
                      type: string
                      description: Error short title
                      example: Service is temporarily unavailable
                    detail:
                      type: string
                      description: Long description of the error
                      example: Please, retry later (check the Retry-After header)
  schemas:
    WalletAddress:
      oneOf:
        - $ref: '#/components/schemas/EVMAddress'
        - $ref: '#/components/schemas/SolanaAddress'
      description: A wallet address, which can be either an EVM or Solana address
    WalletPNLResponse:
      type: object
      required:
        - links
        - data
      properties:
        links:
          $ref: '#/components/schemas/WalletPNLResponseLinks'
        data:
          $ref: '#/components/schemas/WalletPNLContainer'
        meta:
          type: object
          description: >
            Metadata about the PnL calculation (only present when assets were
            excluded from the calculation).

            The structure matches the filter type used in the request:

            - When filtering by `fungible_ids`, the meta contains an
            `excluded_fungible_ids` array

            - When filtering by `fungible_implementations`, the meta contains an
            `excluded_fungible_implementations` array

            - If both filters are used, both fields may appear in the meta
          properties:
            excluded_fungible_ids:
              type: array
              items:
                type: string
              description: >-
                Fungible asset IDs that were excluded due to missing prices
                (only present when the request used fungible_ids filter)
              example:
                - 4a702a34-5cfd-41af-96ad-bd1c45c3672e
            excluded_fungible_implementations:
              type: array
              items:
                type: string
              description: >
                Asset implementations that were excluded due to missing prices
                (only present when the request used fungible_implementations
                filter).

                Format matches the user's query format: "chain:address" for
                regular tokens, "chain:" for base assets.
              example:
                - ethereum:0x6b175474e89094c44da98b954eedeac495271d0f
                - 'ethereum:'
    EVMAddress:
      type: string
      description: Ethereum-compatible address (EVM).
      pattern: ^0x[a-fA-F0-9]{40}$
      example: '0x42b9df65b219b3dd36ff330a4dd8f327a6ada990'
    SolanaAddress:
      type: string
      description: Solana address
      pattern: ^[1-9A-HJ-NP-Za-km-z]{32,44}$
      example: 8BH9pjtgyZDC4iAQH5ZiYDZ1MDWC98xki2V8NzqqKW3K
    WalletPNLResponseLinks:
      type: object
      required:
        - self
      properties:
        self:
          type: string
          format: url
          example: >-
            https://api.zerion.io/v1/wallets/0x42b9df65b219b3dd36ff330a4dd8f327a6ada990/pnl
    WalletPNLContainer:
      type: object
      required:
        - type
        - id
        - attributes
      properties:
        type:
          type: string
          description: Resource type
          enum:
            - pnl
        id:
          type: string
          description: PNL unique ID
          example: '0x42b9df65b219b3dd36ff330a4dd8f327a6ada990'
        attributes:
          $ref: '#/components/schemas/Attributes-2'
    Attributes-2:
      type: object
      properties:
        total_gain:
          type: number
          format: float
          description: >
            Total Gain.


            The sum of realized and unrealized gains across all fungible assets,
            calculated using the FIFO (First In, First Out) method.
          example: -637.8173517
        realized_gain:
          type: number
          format: float
          description: >
            Realized Gain.


            The gain (or loss) realized from the sale of fungible assets,
            calculated using the FIFO (First In, First Out) method (the

            earliest purchases are matched with the earliest sales).

            The cost basis of the oldest assets is subtracted from the sale
            proceeds.
          example: -655.3618983
        unrealized_gain:
          type: number
          format: float
          description: >
            Unrealized Gain.


            The potential gain (or loss) on unsold fungible assets, calculated
            as the difference between their current market value and cost basis
            using the FIFO method (the

            earliest purchases are matched with the earliest sales).
          example: 17.5445466
        relative_total_gain_percentage:
          type: number
          format: float
          description: >
            Relative Total Gain Percentage.


            The percentage return on total investment, combining both realized
            and unrealized gains.
          example: -11.38
        relative_realized_gain_percentage:
          type: number
          format: float
          description: >
            Relative Realized Gain Percentage.


            The percentage return on realized trades, calculated as realized
            gain divided by realized cost basis.
          example: -15.15
        relative_unrealized_gain_percentage:
          type: number
          format: float
          description: >
            Relative Unrealized Gain Percentage.


            The percentage return on open positions, calculated as unrealized
            gain divided by the current cost basis of held assets.
          example: -0.19
        total_fee:
          type: number
          format: float
          description: |
            Total Fees Paid.

            The sum of all transaction fees associated with asset trades.
          example: 281.9088917
        total_invested:
          type: number
          format: float
          description: >
            Total Invested Amount.


            The total amount invested in fungible assets (sum of all buy
            transactions), calculated using the FIFO method.
          example: 701.2
        realized_cost_basis:
          type: number
          format: float
          description: >
            Realized Cost Basis.


            The cost basis of closed (sold) positions, calculated using the FIFO
            method.
          example: 655.36
        net_invested:
          type: number
          format: float
          description: >
            Net Invested Amount.


            The total amount invested in fungible assets that have not been
            sold, calculated using the FIFO method (the earliest purchases are

            matched with the earliest sales).
          example: 45.84218703
        received_external:
          type: number
          format: float
          description: >
            Received Amount from Other Wallets.


            The cumulative value of all fungible assets received from other
            wallets.


            Note: This value does not include amounts traded internally within
            the wallet but does include `received_for_nfts`.
          example: 133971.2931
        sent_external:
          type: number
          format: float
          description: >
            Sent Amount to Other Wallets.


            The cumulative value of all fungible assets sent to other wallets.


            Note: This value does not include amounts traded internally within
            the wallet but does include `sent_for_nfts`.
          example: 133270.089
        sent_for_nfts:
          type: number
          format: float
          description: >
            Sent Amount for NFTs.


            The cumulative value of all fungible assets sent in transactions
            where the wallet receives NFTs.
          example: 133971.2931
        received_for_nfts:
          type: number
          format: float
          description: >
            Received Amount for NFTs.


            The cumulative value of all fungible assets received in transactions
            where the wallet sends NFTs.
          example: 133971.2931
        breakdown:
          $ref: '#/components/schemas/Breakdown'
    Breakdown:
      type: object
      description: >
        Detailed PnL breakdown by individual fungibles.

        Contains per-fungible statistics keyed either by fungible ID or by
        implementation (chain:address pair).

        Only returned when the request includes filters for fungibles
        (fungible_ids or fungible_implementations).
      properties:
        by_id:
          type: object
          description: PnL statistics broken down by fungible ID.
          additionalProperties:
            $ref: '#/components/schemas/Statistics'
          example:
            eth:
              average_buy_price: 1258.8
              average_sell_price: 1224.96
              total_gain: -6900.85
              realized_gain: -6871.21
              unrealized_gain: -29.64
              relative_total_gain_percentage: -11.38
              relative_realized_gain_percentage: -15.15
              relative_unrealized_gain_percentage: -0.19
              total_fee: 4679.93
              total_invested: 60643.33
              realized_cost_basis: 45363.2
              net_invested: 15280.13
              received_external: 35402.73
              sent_external: 22213.21
              sent_for_nfts: 1713.23
              received_for_nfts: 1635.05
        by_implementation:
          type: object
          description: >-
            PnL statistics broken down by fungible implementation (chain:address
            pair).
          additionalProperties:
            $ref: '#/components/schemas/Statistics'
          example:
            ethereum:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48:
              average_buy_price: 1
              average_sell_price: 1
              total_gain: 0
              realized_gain: 0
              unrealized_gain: 0
              relative_total_gain_percentage: 0
              relative_realized_gain_percentage: 0
              relative_unrealized_gain_percentage: 0
              total_fee: 12.5
              total_invested: 5000
              realized_cost_basis: 3000
              net_invested: 2000
              received_external: 1000
              sent_external: 500
              sent_for_nfts: 0
              received_for_nfts: 0
    Statistics:
      type: object
      description: PnL statistics for an individual fungible.
      properties:
        average_buy_price:
          type: number
          format: float
          description: The average price at which the fungible was purchased.
          example: 1258.8
        average_sell_price:
          type: number
          format: float
          description: The average price at which the fungible was sold.
          example: 1224.96
        total_gain:
          type: number
          format: float
          description: The sum of realized and unrealized gains for this fungible.
          example: -6900.85
        realized_gain:
          type: number
          format: float
          description: >-
            The gain (or loss) realized from selling this fungible, calculated
            using the FIFO method.
          example: -6871.21
        unrealized_gain:
          type: number
          format: float
          description: The potential gain (or loss) on unsold holdings of this fungible.
          example: -29.64
        relative_total_gain_percentage:
          type: number
          format: float
          description: The percentage return on total investment for this fungible.
          example: -11.38
        relative_realized_gain_percentage:
          type: number
          format: float
          description: The percentage return on realized trades for this fungible.
          example: -15.15
        relative_unrealized_gain_percentage:
          type: number
          format: float
          description: The percentage return on open positions for this fungible.
          example: -0.19
        total_fee:
          type: number
          format: float
          description: The sum of all transaction fees associated with this fungible.
          example: 4679.93
        total_invested:
          type: number
          format: float
          description: >-
            The total amount invested in this fungible (sum of all buy
            transactions).
          example: 60643.33
        realized_cost_basis:
          type: number
          format: float
          description: The cost basis of closed (sold) positions for this fungible.
          example: 45363.2
        net_invested:
          type: number
          format: float
          description: The total amount invested in this fungible that has not been sold.
          example: 15280.13
        received_external:
          type: number
          format: float
          description: The cumulative value of this fungible received from other wallets.
          example: 35402.73
        sent_external:
          type: number
          format: float
          description: The cumulative value of this fungible sent to other wallets.
          example: 22213.21
        sent_for_nfts:
          type: number
          format: float
          description: >-
            The cumulative value of this fungible sent in transactions where the
            wallet receives NFTs.
          example: 1713.23
        received_for_nfts:
          type: number
          format: float
          description: >-
            The cumulative value of this fungible received in transactions where
            the wallet sends NFTs.
          example: 1635.05
  securitySchemes:
    APIKeyBasicAuth:
      type: http
      scheme: basic
      description: >-
        To test endpoints here, paste your API key from the
        [dashboard](https://dashboard.zerion.io/) into the username field and
        leave the password empty.

````