> ## 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 by ecosystem

> Realized and unrealized PnL for a wallet on the chains of one ecosystem.



## OpenAPI

````yaml /openapi-v1.yaml get /v1/{ecosystem}/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, returning 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/{ecosystem}/wallets/{address}/pnl:
    get:
      tags:
        - wallets
      summary: Get wallet PnL by ecosystem
      description: >
        Returns a wallet's profit and loss (PnL), for a wallet address of the
        ecosystem named in the path. Parameters and responses are the same as
        `GET /v1/wallets/{address}/pnl`, with these differences:


        - The wallet address must be valid for `ecosystem`. Nothing is inferred
        from it.

        - Only chains of `ecosystem` are served. A `filter[chain_ids]` list that
        names no chain of `ecosystem` returns `400`.

        - When no chain of `ecosystem` supports PnL, the request returns `400`,
        with `detail` reading `PnL is not supported for <ecosystem>`.
      operationId: getEcosystemWalletPNL
      parameters:
        - $ref: '#/components/parameters/Ecosystem'
        - $ref: '#/components/parameters/Currency'
        - $ref: '#/components/parameters/EcosystemWalletAddress'
        - $ref: '#/components/parameters/PNLFilterChainIDs'
        - $ref: '#/components/parameters/PNLFilterFungibleIDs'
        - $ref: '#/components/parameters/PNLFilterFungibleImplementations'
        - $ref: '#/components/parameters/PNLSince'
        - $ref: '#/components/parameters/PNLTill'
      responses:
        '200':
          $ref: '#/components/responses/PNLResponse'
        '400':
          $ref: '#/components/responses/MalformedParameters'
        '401':
          $ref: '#/components/responses/UnauthenticatedError'
        '404':
          $ref: '#/components/responses/EcosystemNotFound'
        '422':
          $ref: '#/components/responses/QueryNotSupported'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '503':
          $ref: '#/components/responses/RetryAfter'
components:
  parameters:
    Ecosystem:
      name: ecosystem
      in: path
      required: true
      description: >-
        The ecosystem of the wallet address: `eip155` for EVM chains (`evm` is
        an alias of it), or `solana`. The endpoint serves only chains of this
        ecosystem. An unknown ecosystem returns `404`.
      example: eip155
      schema:
        type: string
        enum:
          - eip155
          - evm
          - solana
    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
    EcosystemWalletAddress:
      name: address
      in: path
      required: true
      description: >-
        The wallet address, valid for the `ecosystem` in the path: a `0x` EVM
        address for `eip155` or `evm`, a Solana address for `solana`. The
        ecosystem is not inferred from the address, so an address of another
        ecosystem returns `400`, for example `wallet address must be a valid
        Solana address`. Under `eip155` and `evm` the zero address returns
        `400`. The transactions, balance chart and PnL endpoints additionally
        require an address Zerion tracks, as they do on `/v1/wallets/{address}/`
        paths. An EVM address that is not tracked, such as a token contract,
        router or exchange hot wallet, returns `400`, with `detail` reading
        `untrackable wallet address` on transactions and balance charts. Solana
        addresses always count as tracked.
      example: '0x42b9df65b219b3dd36ff330a4dd8f327a6ada990'
      schema:
        oneOf:
          - $ref: '#/components/schemas/EVMAddress'
          - $ref: '#/components/schemas/SolanaAddress'
    PNLFilterChainIDs:
      name: filter[chain_ids]
      in: query
      style: form
      explode: false
      description: >-
        Calculate PnL only for specified chains (comma-separated list). A listed
        chain is used only when it reports both `supports_transactions` and
        `supports_positions` in the `flags` of `GET /v1/chains/` and belongs to
        the network family of the wallet address; on `/v1/{ecosystem}/wallets/`
        paths that family is the path's ecosystem. A listed chain that fails
        either rule is ignored when the list also names a chain that passes
        both. When no listed chain passes, the request returns `400` rather than
        an empty result, and `detail` names the first chain in the list, as
        `chain <id> does not support PnL` (for example `chain bob does not
        support PnL`), or `chain <id> does not support this wallet address type`
        when that chain reports those flags but is of another network family.
        When the filter is omitted, chains that fail either rule are left out of
        `data` silently, with no error and no `meta` signal.
      schema:
        type: array
        example:
          - ethereum
          - polygon
        maxItems: 25
        items:
          type: string
    PNLFilterFungibleIDs:
      name: filter[fungible_ids]
      in: query
      style: form
      explode: false
      description: >
        Calculate PnL only for these fungible IDs (comma-separated list, up to
        100).


        With `filter[fungible_ids]` or `filter[fungible_implementations]`,
        assets without a price are left out of the calculation instead of
        causing an error. The excluded assets are listed in the response
        metadata.
      schema:
        type: array
        maxItems: 100
        items:
          type: string
          maxLength: 44
    PNLFilterFungibleImplementations:
      name: filter[fungible_implementations]
      in: query
      style: form
      explode: false
      description: >
        Calculate PnL only for these token implementations (comma-separated list
        of `chain_id:address` pairs, up to 100).


        For example:
        `base:0xae16c445d8a4082cecb49a9465e4dd5499df947d,ethereum:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48`


        The address must be valid for the chain it is given with: an EVM address
        on an EVM chain, a Solana address on `solana`. An address of the other
        network family (for example an EVM address on `solana`) returns `400`.
        EVM addresses are accepted in any letter case; Solana addresses are
        case-sensitive.


        With `filter[fungible_ids]` or `filter[fungible_implementations]`,
        assets without a price are left out of the calculation instead of
        causing an error. The excluded assets are listed in the response
        metadata.


        On `/v1/{ecosystem}/wallets/` paths, an implementation on a chain of
        another ecosystem returns `400`, with `detail` reading `chain <id> does
        not support this wallet address type`.
      schema:
        type: array
        maxItems: 100
        items:
          type: string
    PNLSince:
      name: since
      in: query
      required: false
      description: >
        Count only sales since this time, as 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
    PNLTill:
      name: till
      in: query
      required: false
      description: >
        Count only sales until this time, as 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:
    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
    EcosystemNotFound:
      description: The `ecosystem` in the path is unknown.
    QueryNotSupported:
      description: >
        The request cannot be served and retrying will not change that.


        Unlike a `503`, this response carries no `Retry-After` header. Contact
        support if you

        need the request enabled.
      content:
        application/json:
          schema:
            type: object
            properties:
              errors:
                type: array
                items:
                  type: object
                  properties:
                    title:
                      type: string
                      description: Error short title
                      example: This request is not supported
                    detail:
                      type: string
                      description: Long description of the error
                      example: >-
                        This request cannot be processed, and retrying will not
                        help. Please contact support if you need it enabled.
    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.


        A transient state: the data is being prepared. Retry after the delay
        given in the

        `Retry-After` header. Wallets with long histories can need several
        attempts.
      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:
    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
    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:'
    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.

````

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