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

# Fetch current PnL by Wallet & Token

> Get the PnL for a given wallet and token address.

export const SupportedChainsList = props => {
  const [data, setData] = useState(null);
  const [isLoading, setIsLoading] = useState(true);
  useEffect(() => {
    const fetchData = async () => {
      try {
        const response = await fetch("https://api.allium.so/api/v1/supported-chains/realtime-apis", {
          method: "GET"
        });
        if (!response.ok) {
          throw new Error(`HTTP error! status: ${response.status}`);
        }
        const responseData = await response.json();
        const filteredData = responseData.filter(entry => {
          const product = entry.endpoints[props.product_name];
          return product !== null;
        });
        setData(filteredData);
        setIsLoading(false);
      } catch (error) {
        setIsLoading(false);
      }
    };
    fetchData();
  }, []);
  if (isLoading) {
    return <div>Loading chain information...</div>;
  }
  if (!data) {
    return <div>No data available</div>;
  }
  const isCustomSQL = props.product_name === "custom_sql";
  return <div>
            {data.length > 0 && <table className="w-full">
                    <thead>
                        <tr>
                            <th>Chain</th>
                            <th>Chain ID</th>
                            <th>Status</th>
                            {isCustomSQL && <th>Tables</th>}
                        </tr>
                    </thead>
                    <tbody>
                        {data.map(chain => {
    const endpoint = chain.endpoints[props.product_name];
    return <tr key={chain.id}>
                                    <td style={{
      padding: '12px'
    }}>{chain.label}</td>
                                    <td style={{
      padding: '12px'
    }}><code>{chain.id}</code></td>
                                    <td style={{
      padding: '12px'
    }}>{endpoint ? endpoint.availability === "beta" ? "🌱 Beta" : "✅ Supported" : "❌ Not Supported"}</td>
                                    {isCustomSQL && <td style={{
      padding: '12px'
    }}>
                                            {endpoint && endpoint.tables ? endpoint.tables.map(t => t.name).join(", ") : "-"}
                                        </td>}
                                </tr>;
  })}
                    </tbody>
                </table>}
        </div>;
};

This endpoint provides current PnL metrics for specific wallet and token address combinations, including unrealized PnL, realized PnL, average cost, current balance, and current USD balance.

## Supported Chains

<SupportedChainsList product_name="pnl" />


## OpenAPI

````yaml /_openapi/pnl-api.json POST /api/v1/developer/wallet/pnl-by-token
openapi: 3.1.0
info:
  title: Allium API
  version: 0.1.0
servers:
  - url: https://api.allium.so
security: []
paths:
  /api/v1/developer/wallet/pnl-by-token:
    post:
      tags:
        - PNL
        - DEVELOPER
        - WALLET
      summary: Get Pnl By Token
      operationId: get_pnl_by_token_api_v1_developer_wallet_pnl_by_token_post
      requestBody:
        content:
          application/json:
            schema:
              items:
                $ref: '#/components/schemas/PayloadAddressHoldingsByToken'
              type: array
              maxItems: 20
              minItems: 1
              title: Addresses
              description: Payload for PNL by token.
            example:
              - chain: ethereum
                address: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'
                token_address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/ResponseEnvelope_Union_PnlByToken__PnlError__
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyBearer: []
components:
  schemas:
    PayloadAddressHoldingsByToken:
      properties:
        chain:
          type: string
          title: Chain
          description: Lowercase chain name
        address:
          type: string
          title: Address
          description: Wallet address
        token_address:
          type: string
          title: Token Address
          description: Token contract address
      type: object
      required:
        - chain
        - address
        - token_address
      title: PayloadAddressHoldingsByToken
      examples:
        - address: 125Z6k4ZAxsgdG7JxrKZpwbcS1rxqpAeqM9GSCKd66Wp
          chain: solana
          token_address: So11111111111111111111111111111111111111112
    ResponseEnvelope_Union_PnlByToken__PnlError__:
      properties:
        data:
          anyOf:
            - $ref: '#/components/schemas/PnlByToken'
            - $ref: '#/components/schemas/PnlError'
            - type: 'null'
          title: Data
          description: Single item response data of type T
        items:
          anyOf:
            - items:
                anyOf:
                  - $ref: '#/components/schemas/PnlByToken'
                  - $ref: '#/components/schemas/PnlError'
              type: array
            - type: 'null'
          title: Items
          description: Response items of type T
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
          description: Error message
        cursor:
          anyOf:
            - type: string
            - type: 'null'
          title: Cursor
          description: Pagination cursor for next page
      type: object
      title: ResponseEnvelope[Union[PnlByToken, PnlError]]
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    PnlByToken:
      properties:
        chain:
          type: string
          title: Chain
          description: Lowercase chain name
        address:
          type: string
          title: Address
          description: Wallet address
        token_address:
          type: string
          title: Token Address
          description: Token contract address
        current_tokens:
          type: string
          title: Current Tokens
          description: Current token balance (native units)
        current_balance:
          $ref: '#/components/schemas/CurrencyAmount'
          description: Current token balance (USD)
        current_price:
          $ref: '#/components/schemas/CurrencyAmount'
          description: Current token price (USD)
        unrealized_pnl:
          anyOf:
            - $ref: '#/components/schemas/CurrencyAmount'
            - type: 'null'
          description: Unrealized PnL (USD)
        realized_pnl:
          anyOf:
            - $ref: '#/components/schemas/CurrencyAmount'
            - type: 'null'
          description: Realized PnL (USD)
        average_cost:
          anyOf:
            - $ref: '#/components/schemas/CurrencyAmount'
            - type: 'null'
          description: Average cost basis (USD)
        unrealized_pnl_ratio_change:
          anyOf:
            - type: number
            - type: 'null'
          title: Unrealized Pnl Ratio Change
          description: Unrealized PnL ratio change (decimal)
        attributes:
          anyOf:
            - $ref: '#/components/schemas/TokenAttributes'
            - type: 'null'
          description: Token attributes
        historical_breakdown:
          anyOf:
            - items:
                $ref: '#/components/schemas/PnlDataPerTransaction'
              type: array
            - type: 'null'
          title: Historical Breakdown
          description: Historical breakdown of the token transactions
      type: object
      required:
        - chain
        - address
        - token_address
        - current_tokens
        - current_balance
        - current_price
      title: PnlByToken
    PnlError:
      properties:
        chain:
          type: string
          title: Chain
          description: Lowercase chain name
        address:
          type: string
          title: Address
          description: Wallet address
        message:
          type: string
          title: Message
          description: Error description
      type: object
      required:
        - chain
        - address
        - message
      title: PnlError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    CurrencyAmount:
      properties:
        currency:
          $ref: '#/components/schemas/Currency'
          description: Currency code
          default: USD
        amount:
          type: string
          title: Amount
          description: Value in the specified currency
      type: object
      required:
        - amount
      title: CurrencyAmount
    TokenAttributes:
      properties:
        total_liquidity_usd:
          anyOf:
            - $ref: '#/components/schemas/LiquidityResults'
            - type: 'null'
          description: >-
            Liquidity data: {'amount': number} when available, or {'details':
            'LIQUIDITY_TOO_HIGH'} when limit exceeded
        price_diff_1d:
          anyOf:
            - type: number
            - type: 'null'
          title: Price Diff 1D
          description: Price change (USD) over last 24h
        price_diff_pct_1d:
          anyOf:
            - type: number
            - type: 'null'
          title: Price Diff Pct 1D
          description: Price change (%) over last 24h
        price_diff_1h:
          anyOf:
            - type: number
            - type: 'null'
          title: Price Diff 1H
          description: Price change (USD) over last 1h
        price_diff_pct_1h:
          anyOf:
            - type: number
            - type: 'null'
          title: Price Diff Pct 1H
          description: Price change (%) over last 1h
        total_supply:
          anyOf:
            - type: number
            - type: 'null'
          title: Total Supply
          description: Total token supply
        fully_diluted_valuation_usd:
          anyOf:
            - type: number
            - type: 'null'
          title: Fully Diluted Valuation Usd
          description: Fully diluted valuation (USD)
        volume_1h:
          anyOf:
            - type: number
            - type: 'null'
          title: Volume 1H
          description: Trading volume over last 1h
        volume_1d:
          anyOf:
            - type: number
            - type: 'null'
          title: Volume 1D
          description: Trading volume over last 24h
        volume_usd_1h:
          anyOf:
            - type: number
            - type: 'null'
          title: Volume Usd 1H
          description: Trading volume (USD) over last 1h
        volume_usd_1d:
          anyOf:
            - type: number
            - type: 'null'
          title: Volume Usd 1D
          description: Trading volume (USD) over last 24h
        volume_24h:
          anyOf:
            - type: number
            - type: 'null'
          title: Volume 24H
          description: Trading volume over last 24h
        volume_usd_24h:
          anyOf:
            - type: number
            - type: 'null'
          title: Volume Usd 24H
          description: Trading volume (USD) over last 24h
        trade_count_1h:
          anyOf:
            - type: integer
            - type: 'null'
          title: Trade Count 1H
          description: Trade count over last 1h
        trade_count_1d:
          anyOf:
            - type: integer
            - type: 'null'
          title: Trade Count 1D
          description: Trade count over last 24h
        all_time_high:
          anyOf:
            - type: number
            - type: 'null'
          title: All Time High
          description: All-time high price (USD)
        all_time_low:
          anyOf:
            - type: number
            - type: 'null'
          title: All Time Low
          description: All-time low price (USD)
        image_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Image Url
          description: Token logo URL
        token_creation_time:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Token Creation Time
          description: Token creation timestamp (UTC)
        holders_count:
          anyOf:
            - type: integer
            - type: 'null'
          title: Holders Count
          description: Number of token holders
        stellar_fields:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Stellar Fields
          description: Stellar-specific metadata
      type: object
      title: TokenAttributes
    PnlDataPerTransaction:
      properties:
        trade:
          $ref: '#/components/schemas/Trade'
          description: Trade details
        average_cost:
          anyOf:
            - $ref: '#/components/schemas/CurrencyAmount'
            - type: 'null'
          description: Average cost basis after this trade in USD
        realized_pnl:
          $ref: '#/components/schemas/CurrencyAmount'
          description: Realized PnL from this trade in USD
      type: object
      required:
        - trade
        - average_cost
        - realized_pnl
      title: PnlDataPerTransaction
    Currency:
      type: string
      enum:
        - USD
      title: Currency
    LiquidityResults:
      properties:
        amount:
          anyOf:
            - type: number
            - type: 'null'
          title: Amount
          description: Liquidity amount (USD)
        details:
          anyOf:
            - type: string
            - type: 'null'
          title: Details
          description: Status when amount unavailable (e.g. LIQUIDITY_TOO_HIGH)
      type: object
      title: LiquidityResults
    Trade:
      properties:
        token_address:
          type: string
          title: Token Address
          description: Token contract address
        token_amount:
          type: string
          title: Token Amount
          description: Amount of tokens traded (native units)
        token_price_usd:
          anyOf:
            - type: string
            - type: 'null'
          title: Token Price Usd
          description: Token price at time of trade (USD)
        timestamp:
          type: string
          format: date-time
          title: Timestamp
          description: Trade execution time (UTC)
      type: object
      required:
        - token_address
        - token_amount
        - token_price_usd
        - timestamp
      title: Trade
  securitySchemes:
    APIKeyBearer:
      type: apiKey
      in: header
      name: X-API-KEY

````