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

# Trader token PnL

> Returns a single trader's statistics for a token: buy and sell counts and volumes, net trade cash flow (sell proceeds minus buy spending), current balance and value, and average trade prices and market caps.

```bash theme={null}
curl "https://staging-api.struct.to/v1/trader/pnl/token?chain=robinhood&chain_id=4663&token_address=0x39dBED3a2bd333467115dE45665cC57F813C4571&trader=0x12a371444CCeBb6B64Cc35EBbC70d1d998433d51&fields=short" \
  -H "X-API-Key: YOUR_API_KEY"
```

```json Response (Long) theme={null}
{
  "token": "0x39dBED3a2bd333467115dE45665cC57F813C4571",
  "trader": "0x12a371444CCeBb6B64Cc35EBbC70d1d998433d51",
  "buy_count": 8,
  "sell_count": 5,
  "buy_native": 4.85,
  "buy_usd": 12000.0,
  "buy_tokens": 680000.0,
  "sell_native": 6.22,
  "sell_usd": 15400.0,
  "sell_tokens": 420000.0,
  "pnl_native": 1.37,
  "pnl_usd": 3400.0,
  "pnl_native_percent": 28.25,
  "pnl_usd_percent": 28.33,
  "average_buy_price_usd": 0.01765,
  "average_buy_price_native": 7.13e-06,
  "average_sell_price_usd": 0.03667,
  "average_sell_price_native": 1.481e-05,
  "overall_average_price_usd": 0.0249,
  "overall_average_price_native": 1.006e-05,
  "average_buy_market_cap_usd": 261760.0,
  "average_buy_market_cap_native": 1760.0,
  "average_sell_market_cap_usd": 564290.0,
  "average_sell_market_cap_native": 3810.0,
  "overall_average_market_cap_usd": 377270.0,
  "overall_average_market_cap_native": 2540.0,
  "current_token_balance_usd": 120770.48,
  "current_token_balance_native": 0.0343,
  "current_token_balance": 1250.5,
  "current_token_balance_raw": "1250500000000000000000",
  "current_token_balance_percent_of_supply": 0.125,
  "current_price_native": 3.906497e-05,
  "current_price_usd": 0.09664868619,
  "token_supply": 1000000000,
  "first_active": 1705000000000,
  "last_active": 1710000000000
}
```

```jsonc Response (Short) theme={null}
{
  "tk": "0x39dBED3a2bd333467115dE45665cC57F813C4571",
  "tr": "0x12a371444CCeBb6B64Cc35EBbC70d1d998433d51",
  "bc": 8,
  "sc": 5,
  "bn": 4.85,
  "bu": 12000.0,
  "bt": 680000.0,
  "sn": 6.22,
  "su": 15400.0,
  "st": 420000.0,
  "pnn": 1.37,
  "pu": 3400.0,
  "pnp": 28.25,
  "pup": 28.33,
  "abpu": 0.01765,
  "abpn": 7.13e-06,
  "aspu": 0.03667,
  "aspn": 1.481e-05,
  "oapu": 0.0249,
  "oapn": 1.006e-05,
  "abmcu": 261760.0,
  "abmcn": 1760.0,
  "asmcu": 564290.0,
  "asmcn": 3810.0,
  "oamcu": 377270.0,
  "oamcn": 2540.0,
  "ctbu": 120770.48,
  "ctbn": 0.0343,
  "ctb": 1250.5,
  "ctbr": "1250500000000000000000",
  "ctbp": 0.125,
  "cpn": 3.906497e-05,
  "cpu": 0.09664868619,
  "ts": 1000000000,
  "fa": 1705000000000,
  "la": 1710000000000
}
```


## OpenAPI

````yaml onchain-openapi.json GET /trader/pnl/token
openapi: 3.1.0
info:
  title: Struct On-chain API
  description: >-
    RESTful API for token market data, discovery, holders, audits, and trader
    analytics across supported chains. Pass `fields=short` or header
    `x-field-names: short` for abbreviated keys. HTTP defaults to `long`. Token
    candlesticks, token trades and wallet batch trades also support
    `fields=array` for typed positional rows.
  version: 1.0.0
servers:
  - url: https://staging-api.struct.to/v1
    description: Staging
security:
  - ApiKey: []
paths:
  /trader/pnl/token:
    get:
      tags:
        - Trader
      summary: Trader token PnL
      description: >-
        Returns a single trader's statistics for a token: buy and sell counts
        and volumes, net trade cash flow (sell proceeds minus buy spending),
        current balance and value, and average trade prices and market caps.
      operationId: get_trader_token_pnl
      parameters:
        - name: chain
          in: query
          description: Chain name. Required unless `chain_id` is provided.
          required: false
          schema:
            type: string
          example: robinhood
        - name: chain_id
          in: query
          description: Chain id. Required unless `chain` is provided. Use `-1` for Solana.
          required: false
          schema:
            type: integer
            format: int64
          example: 4663
        - name: token_address
          in: query
          description: Token address (required).
          required: true
          schema:
            type: string
          example: '0x39dBED3a2bd333467115dE45665cC57F813C4571'
        - name: trader
          in: query
          description: Trader wallet address (required).
          required: true
          schema:
            type: string
          example: '0x12a371444CCeBb6B64Cc35EBbC70d1d998433d51'
        - name: timeframe
          in: query
          description: Lookback window (default lifetime).
          required: false
          schema:
            $ref: '#/components/schemas/TraderTimeframe'
        - name: x-field-names
          in: header
          required: false
          description: >-
            Select long (full) or short (abbreviated) field names. HTTP defaults
            to `long`. Takes precedence over `fields`. See [Response
            Format](/api-reference/response-format#long-and-short-field-names).
          schema:
            type: string
            enum:
              - long
              - short
            default: long
          example: short
        - name: fields
          in: query
          required: false
          description: >-
            Same as `x-field-names`. Use `long` or `short`. HTTP defaults to
            `long`. Ignored when the header is set. `field_names` is accepted as
            an alias.
          schema:
            type: string
            enum:
              - long
              - short
            default: long
          example: short
      responses:
        '200':
          description: Trader token PnL stats
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TraderTokenSimpleResponse'
              examples:
                long:
                  summary: Response (Long)
                  value:
                    token: '0x39dBED3a2bd333467115dE45665cC57F813C4571'
                    trader: '0x12a371444CCeBb6B64Cc35EBbC70d1d998433d51'
                    buy_count: 8
                    sell_count: 5
                    buy_native: 4.85
                    buy_usd: 12000
                    buy_tokens: 680000
                    sell_native: 6.22
                    sell_usd: 15400
                    sell_tokens: 420000
                    pnl_native: 1.37
                    pnl_usd: 3400
                    pnl_native_percent: 28.25
                    pnl_usd_percent: 28.33
                    average_buy_price_usd: 0.01765
                    average_buy_price_native: 0.00000713
                    average_sell_price_usd: 0.03667
                    average_sell_price_native: 0.00001481
                    overall_average_price_usd: 0.0249
                    overall_average_price_native: 0.00001006
                    average_buy_market_cap_usd: 261760
                    average_buy_market_cap_native: 1760
                    average_sell_market_cap_usd: 564290
                    average_sell_market_cap_native: 3810
                    overall_average_market_cap_usd: 377270
                    overall_average_market_cap_native: 2540
                    current_token_balance_usd: 120770.48
                    current_token_balance_native: 0.0343
                    current_token_balance: 1250.5
                    current_token_balance_raw: '1250500000000000000000'
                    current_token_balance_percent_of_supply: 0.125
                    current_price_native: 0.00003906497
                    current_price_usd: 0.09664868619
                    token_supply: 1000000000
                    first_active: 1705000000000
                    last_active: 1710000000000
                short:
                  summary: Response (Short)
                  value:
                    tk: '0x39dBED3a2bd333467115dE45665cC57F813C4571'
                    tr: '0x12a371444CCeBb6B64Cc35EBbC70d1d998433d51'
                    bc: 8
                    sc: 5
                    bn: 4.85
                    bu: 12000
                    bt: 680000
                    sn: 6.22
                    su: 15400
                    st: 420000
                    pnn: 1.37
                    pu: 3400
                    pnp: 28.25
                    pup: 28.33
                    abpu: 0.01765
                    abpn: 0.00000713
                    aspu: 0.03667
                    aspn: 0.00001481
                    oapu: 0.0249
                    oapn: 0.00001006
                    abmcu: 261760
                    abmcn: 1760
                    asmcu: 564290
                    asmcn: 3810
                    oamcu: 377270
                    oamcn: 2540
                    ctbu: 120770.48
                    ctbn: 0.0343
                    ctb: 1250.5
                    ctbr: '1250500000000000000000'
                    ctbp: 0.125
                    cpn: 0.00003906497
                    cpu: 0.09664868619
                    ts: 1000000000
                    fa: 1705000000000
                    la: 1710000000000
        '400':
          description: >-
            Validation error — missing `token_address`/`trader`, invalid
            `timeframe`, or invalid address.
components:
  schemas:
    TraderTimeframe:
      type: string
      description: Lookback window for trader PnL endpoints.
      enum:
        - 1d
        - 3d
        - 7d
        - 14d
        - 30d
        - lifetime
    TraderTokenSimpleResponse:
      type: object
      properties:
        token:
          type:
            - string
            - 'null'
        trader:
          type:
            - string
            - 'null'
        buy_count:
          type:
            - integer
            - 'null'
          format: int64
          minimum: 0
        sell_count:
          type:
            - integer
            - 'null'
          format: int64
          minimum: 0
        buy_native:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Decimal'
        buy_usd:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Decimal'
        buy_tokens:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Decimal'
        sell_native:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Decimal'
        sell_usd:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Decimal'
        sell_tokens:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Decimal'
        pnl_native:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Decimal'
        pnl_usd:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Decimal'
        pnl_native_percent:
          type:
            - number
            - 'null'
          format: double
        pnl_usd_percent:
          type:
            - number
            - 'null'
          format: double
        average_buy_price_native:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Decimal'
        average_buy_price_usd:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Decimal'
        average_sell_price_native:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Decimal'
        average_sell_price_usd:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Decimal'
        overall_average_price_native:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Decimal'
        overall_average_price_usd:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Decimal'
        average_buy_market_cap_native:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Decimal'
        average_buy_market_cap_usd:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Decimal'
        average_sell_market_cap_native:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Decimal'
        average_sell_market_cap_usd:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Decimal'
        overall_average_market_cap_native:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Decimal'
        overall_average_market_cap_usd:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Decimal'
        current_token_balance_usd:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Decimal'
        current_token_balance_native:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Decimal'
        current_token_balance:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Decimal'
        current_token_balance_raw:
          type:
            - string
            - 'null'
        current_token_balance_percent_of_supply:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Decimal'
        first_active:
          type:
            - integer
            - 'null'
          format: int64
        last_active:
          type:
            - integer
            - 'null'
          format: int64
        current_price_native:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Decimal'
        current_price_usd:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Decimal'
        token_supply:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Decimal'
    Decimal:
      type: number
      format: double
      description: Floating-point number serialized as JSON number.
      examples:
        - 4.108801574e-7
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: Secret API key (`sk_*`) or JWT public key (`pk_jwt_*`).

````

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