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

# PnL by Wallet Address

> To query the PnL of a wallet address across networks

export const CacheInfo = ({publicRate, paidRate, rate}) => {
  const fmt = v => v === 0 ? 'Real-time (Cacheless)' : `Every ${v}`;
  if (rate !== undefined) {
    return <Callout icon="clock-rotate-left" color="#2196F3" iconType="regular">
        <strong>Cache / Update Frequency:</strong><br />{fmt(rate)}
      </Callout>;
  }
  if (publicRate !== undefined && paidRate !== undefined) {
    return <Callout icon="clock-rotate-left" color="#2196F3" iconType="regular">
        <strong>Cache / Update Frequency:</strong><ul><li>{fmt(paidRate)} (Paid API)</li><li>{fmt(publicRate)} (Demo / Keyless API)</li></ul>
      </Callout>;
  }
  return null;
};

export const PlanExclusivity = ({tier}) => {
  if (tier === "enterprise") {
    return <Callout icon="crown" color="#FFC107" iconType="regular">
        <strong>Enterprise Only</strong><br />This endpoint is exclusively available to <strong>Enterprise</strong> plan.<br /><a href="https://www.coingecko.com/en/api/enterprise">→ Contact sales</a>
      </Callout>;
  }
  if (tier === "analyst_above") {
    return <Callout icon="briefcase" color="#FFC107" iconType="regular">
        <strong>Analyst Plan and Above</strong><br />This endpoint is only available to <strong>Analyst, Lite, Pro, and Enterprise</strong> plan.<br /><a href="https://www.coingecko.com/en/api/pricing">→ View pricing</a>
      </Callout>;
  }
  if (tier === "basic_above") {
    return <Callout icon="briefcase" color="#FFC107" iconType="regular">
        <strong>Basic Plan and Above</strong><br />This endpoint is only available to <strong>Basic, Analyst, Lite, Pro, and Enterprise</strong> plan.<br /><a href="https://www.coingecko.com/en/api/pricing">→ View pricing</a>
      </Callout>;
  }
  throw new Error(`PlanExclusivity: invalid tier "${tier}". Use "basic_above", "analyst_above", or "enterprise".`);
};

#### Notes

* Use the `sort` param to rank tokens by PnL, buy or sell volume, or balance.

<Warning>
  Every network in one request must belong to the same VM family, or the request returns a `400`.

  * For example, `networks=eth,base,arbitrum` is valid because all three are EVM.
  * Networks from different VM families must be queried in separate calls.
</Warning>

<PlanExclusivity tier="analyst_above" />

<CacheInfo rate="60 seconds" />


## OpenAPI

````yaml openapi-specs/pro-api.json get /onchain/wallets/{address}/pnl
openapi: 3.0.0
info:
  title: CoinGecko Pro API
  version: 3.0.0
servers:
  - url: https://pro-api.coingecko.com/api/v3
security:
  - headerAuth: []
  - queryAuth: []
paths:
  /onchain/wallets/{address}/pnl:
    get:
      summary: PnL by Wallet Address
      description: To query the PnL of a wallet address across networks
      operationId: wallet-pnl
      parameters:
        - name: address
          in: path
          required: true
          description: Wallet address.
          schema:
            type: string
            default: '0x4b3f1048c55faa0c0873e249e541139360501f2a'
        - name: networks
          in: query
          required: true
          description: |-
            Query PnL by networks, comma-separated if more than one. 
            *refers to [`/onchain/networks`](/reference/networks-list).
          schema:
            type: string
            default: eth,base
        - name: sort
          in: query
          required: false
          description: |-
            Sort the token stats by field. 
            Default: `realized_pnl_usd_desc`
          schema:
            type: string
            enum:
              - realized_pnl_usd_desc
              - unrealized_pnl_usd_desc
              - total_buy_usd_desc
              - total_sell_usd_desc
              - token_balance_desc
        - name: page
          in: query
          required: false
          description: |-
            Page through results. 
            Default value: 1
          schema:
            type: integer
        - name: per_page
          in: query
          required: false
          description: |-
            Total results per page. 
            Default value: 100 
            Valid values: 1...300
          schema:
            type: integer
      responses:
        '200':
          description: Wallet PnL data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WalletPnl'
              example:
                data:
                  id: '0x4b3f1048c55faa0c0873e249e541139360501f2a'
                  type: wallet_pnl
                  attributes:
                    wallet_address: '0x4b3f1048c55faa0c0873e249e541139360501f2a'
                    total_realized_pnl_usd: '17831328.189418429'
                    total_unrealized_pnl_usd: '-5265158.4349284421'
                    total_tokens: 47
                    networks:
                      - network: eth
                        realized_pnl_usd: '13365120.67931429'
                        unrealized_pnl_usd: '-1425379.6227395136'
                        tokens: 35
                      - network: base
                        realized_pnl_usd: '4466207.510104139'
                        unrealized_pnl_usd: '-3839778.8121889285'
                        tokens: 12
                    token_stats:
                      - network: eth
                        address: '0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0'
                        name: Wrapped liquid staked Ether 2.0
                        symbol: wstETH
                        decimals: 18
                        realized_pnl_usd: '4301337.150173959'
                        unrealized_pnl_usd: null
                        token_balance: null
                        average_buy_price_usd: '3948.371209968930021553881069349236062352'
                        average_sell_price_usd: '3711.766598724373102968109799056730691612'
                        total_buy_count: 13
                        total_sell_count: 15
                        total_buy_token_amount: '1999.0764297846674'
                        total_sell_token_amount: '3285.344767166688'
                        total_buy_usd: '7893095.821889256'
                        total_sell_usd: '12194432.972063215'
                      - network: base
                        address: '0xb095274743941e953c746f9c228da9c18bb6ec29'
                        name: LAPTOP
                        symbol: LAPTOP
                        decimals: 18
                        realized_pnl_usd: '2148309.480276389'
                        unrealized_pnl_usd: null
                        token_balance: null
                        average_buy_price_usd: '0.0'
                        average_sell_price_usd: '3.621834900281358161020306665'
                        total_buy_count: 0
                        total_sell_count: 416
                        total_buy_token_amount: '0.0'
                        total_sell_token_amount: '593155.0'
                        total_buy_usd: '0.0'
                        total_sell_usd: '2148309.480276389'
components:
  schemas:
    WalletPnl:
      type: object
      required:
        - data
      properties:
        data:
          type: object
          required:
            - id
            - type
            - attributes
          properties:
            id:
              type: string
              description: Wallet address
            type:
              type: string
              description: Response type
            attributes:
              type: object
              required:
                - wallet_address
                - total_realized_pnl_usd
                - total_unrealized_pnl_usd
                - total_tokens
                - networks
                - token_stats
              properties:
                wallet_address:
                  type: string
                  description: Wallet address queried
                total_realized_pnl_usd:
                  type: string
                  description: >-
                    All-time realized PnL in USD, across the requested networks
                    only
                total_unrealized_pnl_usd:
                  type: string
                  description: >-
                    All-time unrealized PnL in USD, across the requested
                    networks only
                total_tokens:
                  type: integer
                  description: Number of tokens traded across the requested networks only
                networks:
                  type: array
                  description: >-
                    Realized PnL, unrealized PnL and token count per network,
                    listing only networks where the wallet traded
                  items:
                    type: object
                    required:
                      - network
                      - realized_pnl_usd
                      - unrealized_pnl_usd
                      - tokens
                    properties:
                      network:
                        type: string
                        description: Network ID
                      realized_pnl_usd:
                        type: string
                        description: Realized PnL on this network in USD
                      unrealized_pnl_usd:
                        type: string
                        description: Unrealized PnL on this network in USD
                      tokens:
                        type: integer
                        description: Number of tokens traded on this network
                token_stats:
                  type: array
                  description: Trading stats and PnL, one entry per token
                  items:
                    type: object
                    required:
                      - network
                      - address
                      - name
                      - symbol
                      - decimals
                      - realized_pnl_usd
                      - unrealized_pnl_usd
                      - token_balance
                      - average_buy_price_usd
                      - average_sell_price_usd
                      - total_buy_count
                      - total_sell_count
                      - total_buy_token_amount
                      - total_sell_token_amount
                      - total_buy_usd
                      - total_sell_usd
                    properties:
                      network:
                        type: string
                        description: Network ID
                      address:
                        type: string
                        description: Token contract address
                      name:
                        type: string
                        description: Token name
                      symbol:
                        type: string
                        description: Token symbol
                      decimals:
                        type: integer
                        description: Token decimals
                      realized_pnl_usd:
                        type: string
                        description: Realized PnL in USD
                      unrealized_pnl_usd:
                        type: string
                        nullable: true
                        description: Unrealized PnL in USD
                      token_balance:
                        type: string
                        nullable: true
                        description: Current token balance
                      average_buy_price_usd:
                        type: string
                        description: Average buy price in USD
                      average_sell_price_usd:
                        type: string
                        description: Average sell price in USD
                      total_buy_count:
                        type: integer
                        description: Total number of buy transactions
                      total_sell_count:
                        type: integer
                        description: Total number of sell transactions
                      total_buy_token_amount:
                        type: string
                        description: Total buy token amount
                      total_sell_token_amount:
                        type: string
                        description: Total sell token amount
                      total_buy_usd:
                        type: string
                        description: Total buy amount in USD
                      total_sell_usd:
                        type: string
                        description: Total sell amount in USD
  securitySchemes:
    headerAuth:
      type: apiKey
      in: header
      name: x-cg-pro-api-key
      description: >-
        Learn how to [set up your API
        key](https://docs.coingecko.com/docs/setting-up-your-api-key)
    queryAuth:
      type: apiKey
      in: query
      name: x_cg_pro_api_key
      description: >-
        Learn how to [set up your API
        key](https://docs.coingecko.com/docs/setting-up-your-api-key)

````