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

# Wallet - PnL By Token

> Get PnL for specific tokens in a wallet



## OpenAPI

````yaml /en/api-reference/openapi-data-en.yaml GET /v2/wallet/{chain}/{walletAddress}/pnl-by-token
openapi: 3.1.0
info:
  title: Services API
  description: Services API
  contact:
    name: AI
    email: ai@sx.ai
  license:
    name: MIT
  version: '1.0'
servers:
  - url: https://api.chainstream.io
    description: Production
security:
  - bearer_auth: []
  - api_key_auth: []
tags:
  - name: Blockchain
    description: Blockchain related operations
  - name: Token
    description: Token related operations
  - name: Trade
    description: Trade related operations
  - name: Wallet
    description: Wallet related operations
  - name: Dex
    description: Dex related operations
  - name: Ranking
    description: Ranking related operations
  - name: DexPool
    description: DexPool related operations
  - name: Watchlist
    description: Watchlist related operations
  - name: KYT
    description: Kyt related operations
  - name: Webhook
    description: Webhook related operations
  - name: RedPacket
    description: Redpacket related operations
  - name: IPFS
    description: Ipfs related operations
  - name: DexScreener
    description: DexScreener related operations
paths:
  /v2/wallet/{chain}/{walletAddress}/pnl-by-token:
    get:
      tags:
        - Wallet
      summary: Wallet - PnL By Token
      description: Get PnL for specific tokens in a wallet
      operationId: get.pnl.by.token
      parameters:
        - name: chain
          in: path
          description: A chain name listed in supported networks
          required: true
          schema:
            $ref: '#/components/schemas/ChainSymbol'
          example: sol
        - name: walletAddress
          in: path
          description: An address of a wallet
          required: true
          schema:
            type: string
          example: 54Pz1e35z9uoFdnxtzjp7xZQoFiofqhdayQWBMN7dsuy
        - name: tokenAddresses
          in: query
          description: >-
            A list of token addresses in string separated by commas (,). Maximum
            100 token addresses allowed
          required: true
          schema:
            type: string
          example: >-
            4MbgMQGvXBWyxKsTfrvkcRgh5FNLg1VxLnzWqbsdPh7p,EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v,EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
        - name: resolution
          in: query
          description: Time resolution for PnL aggregation
          required: false
          schema:
            oneOf:
              - $ref: '#/components/schemas/PnlResolution'
            default: 1d
          example: 1d
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PnlDetailsResult'
components:
  schemas:
    ChainSymbol:
      type: string
      description: Supported blockchain chains
      enum:
        - sol
        - eth
        - bsc
    PnlResolution:
      type: string
      description: PnL resolution period
      enum:
        - 1d
        - 7d
        - 30d
        - all
    PnlDetailsResult:
      type: object
      description: Full PnL details result with cursor pagination.
      required:
        - summary
        - data
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/PnlDetailItem'
          description: List of per-token PnL details
        endCursor:
          type:
            - string
            - 'null'
          description: Cursor for the end of current page
          example: eyJpZCI6ImVuZCJ9
        hasNext:
          type: boolean
          description: Whether there is a next page
          example: false
        hasPrev:
          type: boolean
          description: Whether there is a previous page
          example: false
        startCursor:
          type:
            - string
            - 'null'
          description: Cursor for the start of current page
          example: eyJpZCI6InN0YXJ0In0=
        summary:
          $ref: '#/components/schemas/PnlDetailSummary'
          description: Aggregated PnL summary
    PnlDetailItem:
      type: object
      description: PnL detail for a single wallet-token pair (mirrors TS PnlDetailItemDTO).
      required:
        - tokenAddress
        - walletAddress
        - balance
        - priceInUsd
        - currentValue
        - buys
        - sells
        - totalTrades
        - buyAmount
        - sellAmount
        - buyAmountInUsd
        - sellAmountInUsd
        - avgBuyPriceInUsd
        - avgSellPriceInUsd
        - realizedProfitInUsd
        - realizedProfitRatio
        - unrealizedProfitInUsd
        - unrealizedProfitRatio
        - totalProfitInUsd
        - totalProfitRatio
        - avgProfitPerTradeInUsd
        - isClosed
      properties:
        avgBuyPriceInUsd:
          type: string
          description: Average buy price in USD
          example: '0.00003324391014165111'
        avgProfitPerTradeInUsd:
          type: string
          description: Average profit per trade in USD
          example: '3206068.5728287027967835484926836364'
        avgSellPriceInUsd:
          type: string
          description: Average sell price in USD
          example: '0.00003185807445122603'
        balance:
          type: string
          description: Current token balance
          example: '1254982158.7106050000000000'
        buyAmount:
          type: string
          description: Total buy amount in token units
          example: '1457986404.2130240000000000'
        buyAmountInUsd:
          type: string
          description: Total buy amount in USD
          example: '48469.1690094067802589'
        buys:
          type: string
          description: Number of buy trades
          example: '275'
        currentValue:
          type: string
          description: Current holding value in USD
          example: '1062513957.429816153652557077014'
        decimals:
          type: integer
          format: int32
          description: Token decimal places
          example: 6
        firstBuyAt:
          type:
            - integer
            - 'null'
          format: int64
          description: Timestamp of first buy (ms since epoch)
        isClosed:
          type: boolean
          description: Whether the position is fully closed (balance == 0)
        lastSellAt:
          type:
            - integer
            - 'null'
          format: int64
          description: Timestamp of last sell (ms since epoch)
        logoUri:
          type:
            - string
            - 'null'
          description: Token logo URI
          example: https://s1.chainstream.io/tokens/images/example.webp
        losses:
          type:
            - string
            - 'null'
          description: Number of losing trades
          example: '5'
        name:
          type: string
          description: Token display name
          example: The Real World
        priceInUsd:
          type: string
          description: Current token price in USD
          example: '0.8466367032033868'
        realizedProfitInUsd:
          type: string
          description: Realized profit in USD
          example: '67.1297848453256596'
        realizedProfitRatio:
          type: string
          description: Realized profit ratio
          example: '0.00138499970635554473'
        sellAmount:
          type: string
          description: Total sell amount in token units
          example: '203004245.5024190000000000'
        sellAmountInUsd:
          type: string
          description: Total sell amount in USD
          example: '6467.3243671310312402'
        sells:
          type: string
          description: Number of sell trades
          example: '110'
        symbol:
          type: string
          description: Token ticker symbol
          example: TRW
        tokenAddress:
          type: string
          description: Token contract address
          example: 4MbgMQGvXBWyxKsTfrvkcRgh5FNLg1VxLnzWqbsdPh7p
        totalCostInUsd:
          type:
            - string
            - 'null'
          description: Total cost basis in USD
          example: '48469.17'
        totalProfitInUsd:
          type: string
          description: Total profit (realized + unrealized) in USD
          example: '1234336400.539050576761666169683200000000'
        totalProfitRatio:
          type: string
          description: Total profit ratio
          example: '25466.423827061972608618047859693225'
        totalTrades:
          type: string
          description: Total number of trades
          example: '385'
        transferInAmountInUsd:
          type:
            - string
            - 'null'
          description: Total value transferred in, in USD
          example: '150.00'
        transferInCount:
          type:
            - string
            - 'null'
          description: Number of transfer-in events
          example: '3'
        transferOutAmountInUsd:
          type:
            - string
            - 'null'
          description: Total value transferred out, in USD
          example: '29.40'
        transferOutCount:
          type:
            - string
            - 'null'
          description: Number of transfer-out events
          example: '1'
        unrealizedProfitInUsd:
          type: string
          description: Unrealized profit in USD
          example: '1234336333.409265731436006569683200000000'
        unrealizedProfitRatio:
          type: string
          description: Unrealized profit ratio
          example: '25466.422442062266253073315832775971'
        walletAddress:
          type: string
          description: Wallet address
          example: 54Pz1e35z9uoFdnxtzjp7xZQoFiofqhdayQWBMN7dsuy
        wins:
          type:
            - string
            - 'null'
          description: Number of winning trades
          example: '12'
    PnlDetailSummary:
      type: object
      description: >-
        Aggregated PnL summary across all items (mirrors TS
        PnlDetailSummaryDTO).
      required:
        - tokens
        - buys
        - sells
        - totalTrades
        - wins
        - losses
        - winRate
        - buyAmountInUsd
        - sellAmountInUsd
        - totalCostInUsd
        - currentValue
        - realizedProfitInUsd
        - realizedProfitRatio
        - unrealizedProfitInUsd
        - totalProfitInUsd
        - avgProfitPerTradeInUsd
      properties:
        avgProfitPerTradeInUsd:
          type: string
          description: Average profit per trade in USD
          example: '3206068.5728287027967835484926836364'
        buyAmountInUsd:
          type: string
          description: Total buy amount in USD
          example: '48469.1690094067802589'
        buys:
          type: string
          description: Total buy trades
          example: '275'
        currentValue:
          type: string
          description: Current total holding value in USD
          example: '1062513957.429816153652557077014'
        losses:
          type: string
          description: Number of losing trades
          example: '69'
        realizedProfitInUsd:
          type: string
          description: Total realized profit in USD
          example: '67.1297848453256596'
        realizedProfitRatio:
          type: string
          description: Total realized profit ratio
          example: '0.0013849997063555447320269173'
        sellAmountInUsd:
          type: string
          description: Total sell amount in USD
          example: '6467.3243671310312402'
        sells:
          type: string
          description: Total sell trades
          example: '110'
        tokens:
          type: string
          description: Total number of traded tokens
          example: '1'
        totalCostInUsd:
          type: string
          description: Total cost basis in USD
          example: '48469.1690094067802589'
        totalProfitInUsd:
          type: string
          description: Total profit in USD
          example: '1234336400.5390505767616661696832'
        totalTrades:
          type: string
          description: Total number of trades
          example: '385'
        transferInAmountInUsd:
          type: string
          description: Total value transferred in, in USD
          example: '350.00'
        transferInCount:
          type: string
          description: Number of transfer-in events
          example: '5'
        transferOutAmountInUsd:
          type: string
          description: Total value transferred out, in USD
          example: '29.40'
        transferOutCount:
          type: string
          description: Number of transfer-out events
          example: '2'
        unrealizedProfitInUsd:
          type: string
          description: Total unrealized profit in USD
          example: '1234336333.4092657314360065696832'
        winRate:
          type: string
          description: Win rate ratio
          example: '0.5688'
        wins:
          type: string
          description: Number of profitable trades
          example: '91'
  securitySchemes:
    bearer_auth:
      type: http
      scheme: bearer
      bearerFormat: JWT
    api_key_auth:
      type: apiKey
      in: header
      name: X-API-KEY

````