> ## 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 historical PnL by Wallet & Token

> Get the Historical PnL for a given wallet address 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 unrealized and realized PnL for specific wallet and token address combinations at specified time periods and granularities.

## Time Range Parameters

* `start_timestamp` - Beginning of the time range (inclusive)
* `end_timestamp` - End of the time range (exclusive)
* Both timestamps are assumed to be in UTC if no timezone is specified
* All returned data is in UTC

## Granularity Options

* `1d` - Daily intervals
* `1h` - Hourly intervals

## Supported Chains

<SupportedChainsList product_name="pnl" />


## OpenAPI

````yaml /_openapi/pnl-api.json POST /api/v1/developer/wallet/pnl-by-token/history
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/history:
    post:
      tags:
        - PNL
        - DEVELOPER
        - WALLET
      summary: Get Pnl By Token With Historical Breakdown
      operationId: >-
        get_pnl_by_token_with_historical_breakdown_api_v1_developer_wallet_pnl_by_token_history_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PayloadHistoricalPnlByToken'
              description: Payload for historical PNL by token.
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/ResponseEnvelope_Union_HistoricalPnlByToken__PnlError__
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyBearer: []
components:
  schemas:
    PayloadHistoricalPnlByToken:
      properties:
        start_timestamp:
          type: string
          format: date-time
          title: Start Timestamp
          description: Start of time range (UTC ISO 8601)
        end_timestamp:
          type: string
          format: date-time
          title: End Timestamp
          description: End of time range (UTC ISO 8601)
        granularity:
          $ref: '#/components/schemas/PnlGranularity'
          description: Time interval granularity (1d, 1h, 5m, 1m, 15s)
        addresses:
          items:
            $ref: '#/components/schemas/PayloadAddressHoldingsByToken'
          type: array
          maxItems: 20
          minItems: 1
          title: Addresses
          description: List of wallet chain+address+token triples
      type: object
      required:
        - start_timestamp
        - end_timestamp
        - granularity
        - addresses
      title: PayloadHistoricalPnlByToken
      example:
        addresses:
          - address: 125Z6k4ZAxsgdG7JxrKZpwbcS1rxqpAeqM9GSCKd66Wp
            chain: solana
            token_address: So11111111111111111111111111111111111111112
        end_timestamp: '2025-04-10T00:00:00Z'
        granularity: 1h
        start_timestamp: '2025-04-01T00:00:00Z'
    ResponseEnvelope_Union_HistoricalPnlByToken__PnlError__:
      properties:
        data:
          anyOf:
            - $ref: '#/components/schemas/HistoricalPnlByToken'
            - $ref: '#/components/schemas/PnlError'
            - type: 'null'
          title: Data
          description: Single item response data of type T
        items:
          anyOf:
            - items:
                anyOf:
                  - $ref: '#/components/schemas/HistoricalPnlByToken'
                  - $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[HistoricalPnlByToken, PnlError]]
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    PnlGranularity:
      type: string
      enum:
        - 1h
        - 1d
        - 1m
        - 5m
        - 15s
      title: PnlGranularity
    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
    HistoricalPnlByToken:
      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
        pnl:
          items:
            $ref: '#/components/schemas/TimeIntervalPnl'
          type: array
          title: Pnl
          description: PnL snapshots per time interval
      type: object
      required:
        - chain
        - address
        - token_address
        - pnl
      title: HistoricalPnlByToken
    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
    TimeIntervalPnl:
      properties:
        timestamp:
          type: string
          format: date-time
          title: Timestamp
          description: Interval start time (UTC)
        unrealized_pnl:
          $ref: '#/components/schemas/CurrencyAmount'
          description: Unrealized PnL at this interval (USD)
        realized_pnl:
          $ref: '#/components/schemas/CurrencyAmount'
          description: Cumulative realized PnL at this interval (USD)
      type: object
      required:
        - timestamp
        - unrealized_pnl
        - realized_pnl
      title: TimeIntervalPnl
    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
    Currency:
      type: string
      enum:
        - USD
      title: Currency
  securitySchemes:
    APIKeyBearer:
      type: apiKey
      in: header
      name: X-API-KEY

````