> ## 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 PnL candles

> Returns a trader's PnL candles, oldest first: one per bucket with trades, carrying the cumulative PnL (USD and native) up to that bucket and the PnL made within it. Pages hold at most 2,500 buckets; follow `pagination.pagination_key` for the next page.

Each candle carries the trader's total PnL at the end of its bucket (including every trade before the window starts, so the series plots directly as a PnL chart) and the PnL made within the bucket. Only buckets with trades are returned.

| `range` | Default window | Default bucket |
| - | - | - |
| `1d` | 24 hours | 1 hour |
| `7d` | 7 days | 4 hours |
| `1m` | 30 days | 1 day |
| `1y` | 365 days | 1 week |
| `all` (default) | Since the first trade | 1 day |

* `bucket_seconds` overrides the bucket width: whole minutes up to a day, or whole days up to a week.
* `from` / `to` (unix seconds) override the window.
* Pages hold at most 2,500 buckets (`limit`). When `pagination.has_more` is true, pass `pagination.pagination_key` back to get the next page.

Candle fields (short keys with `fields=short`):

| Field | Short | Meaning |
| - | - | - |
| `time` | `t` | Bucket start (Unix milliseconds) |
| `pnl_usd` | `pu` | Cumulative PnL in USD at the end of the bucket |
| `pnl_native` | `pn` | Cumulative PnL in the chain's native token at the end of the bucket |
| `pnl_delta_usd` | `du` | PnL in USD made within the bucket |
| `pnl_delta_native` | `dn` | PnL in the native token made within the bucket |

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

```json Response (Long) theme={null}
{
  "trader": "0x12a371444ccebb6b64cc35ebbc70d1d998433d51",
  "range": "7d",
  "bucket_seconds": 14400,
  "candles": [
    {
      "time": 1758585600000,
      "pnl_usd": 125.4,
      "pnl_native": 0.031,
      "pnl_delta_usd": 18.2,
      "pnl_delta_native": 0.0045
    },
    {
      "time": 1758600000000,
      "pnl_usd": 142.9,
      "pnl_native": 0.035,
      "pnl_delta_usd": 17.5,
      "pnl_delta_native": 0.0043
    }
  ]
}
```

```jsonc Response (Short) theme={null}
{
  "tr": "0x12a371444ccebb6b64cc35ebbc70d1d998433d51",
  "r": "7d",
  "bs": 14400,
  "c": [
    {
      "t": 1758585600000,
      "pu": 125.4,
      "pn": 0.031,
      "du": 18.2,
      "dn": 0.0045
    },
    {
      "t": 1758600000000,
      "pu": 142.9,
      "pn": 0.035,
      "du": 17.5,
      "dn": 0.0043
    }
  ]
}
```


## OpenAPI

````yaml onchain-openapi.json GET /trader/pnl/candles
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/candles:
    get:
      tags:
        - Trader
      summary: Trader PnL candles
      description: >-
        Returns a trader's PnL candles, oldest first: one per bucket with
        trades, carrying the cumulative PnL (USD and native) up to that bucket
        and the PnL made within it. Pages hold at most 2,500 buckets; follow
        `pagination.pagination_key` for the next page.
      operationId: get_trader_pnl_candles
      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: trader
          in: query
          description: Trader wallet address (required).
          required: true
          schema:
            type: string
          example: '0x12a371444CCeBb6B64Cc35EBbC70d1d998433d51'
        - name: range
          in: query
          description: >-
            `1d` (hourly), `7d` (4-hourly), `1m` (daily), `1y` (weekly) or `all`
            (daily since the first trade). Sets the default window and bucket.
            Default `all`.
          required: false
          schema:
            type: string
          example: 7d
        - name: bucket_seconds
          in: query
          description: >-
            Override the bucket width: whole minutes up to 86400, or whole days
            up to 604800.
          required: false
          schema:
            type: integer
            format: int64
        - name: from
          in: query
          description: Window start (unix seconds). Defaults to the range's lookback.
          required: false
          schema:
            type: integer
            format: int64
        - name: to
          in: query
          description: Window end (unix seconds). Defaults to now.
          required: false
          schema:
            type: integer
            format: int64
        - name: limit
          in: query
          description: >-
            Buckets per page, at most 2500. Defaults to the range's bucket
            count.
          required: false
          schema:
            type: integer
            minimum: 0
        - name: pagination_key
          in: query
          description: Opaque key from the previous page's `pagination.pagination_key`.
          required: false
          schema:
            type: string
        - 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 PnL candles
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TraderPnlCandlesResponse'
              examples:
                long:
                  summary: Response (Long)
                  value:
                    trader: '0x12a371444ccebb6b64cc35ebbc70d1d998433d51'
                    range: 7d
                    bucket_seconds: 14400
                    candles:
                      - time: 1758585600000
                        pnl_usd: 125.4
                        pnl_native: 0.031
                        pnl_delta_usd: 18.2
                        pnl_delta_native: 0.0045
                      - time: 1758600000000
                        pnl_usd: 142.9
                        pnl_native: 0.035
                        pnl_delta_usd: 17.5
                        pnl_delta_native: 0.0043
                short:
                  summary: Response (Short)
                  value:
                    tr: '0x12a371444ccebb6b64cc35ebbc70d1d998433d51'
                    r: 7d
                    bs: 14400
                    c:
                      - t: 1758585600000
                        pu: 125.4
                        pn: 0.031
                        du: 18.2
                        dn: 0.0045
                      - t: 1758600000000
                        pu: 142.9
                        pn: 0.035
                        du: 17.5
                        dn: 0.0043
        '400':
          description: >-
            Validation error — missing or invalid `trader`, `range`,
            `bucket_seconds`, `from`/`to`, `limit` or `pagination_key`.
components:
  schemas:
    TraderPnlCandlesResponse:
      type: object
      required:
        - trader
        - range
        - bucket_seconds
        - candles
      properties:
        trader:
          type: string
        range:
          type: string
          description: 'Requested range: `1d`, `7d`, `1m`, `1y` or `all`.'
        bucket_seconds:
          type: integer
          format: int64
          description: Bucket width in seconds.
        candles:
          type: array
          items:
            $ref: '#/components/schemas/TraderPnlCandle'
          description: Buckets with trades, oldest first.
    TraderPnlCandle:
      type: object
      description: One PnL candle.
      required:
        - time
        - pnl_usd
        - pnl_native
        - pnl_delta_usd
        - pnl_delta_native
      properties:
        time:
          type: integer
          format: int64
          description: >-
            Bucket start, in milliseconds. (`from`/`to` query parameters and

            `bucket_seconds` stay in seconds, as on
            `/token/market/candlestick`.)
        pnl_usd:
          type: number
          format: double
          description: Cumulative PnL in USD at the end of this bucket (all trades so far).
        pnl_native:
          type: number
          format: double
          description: >-
            Cumulative PnL in the chain's native token at the end of this
            bucket.
        pnl_delta_usd:
          type: number
          format: double
          description: PnL (USD) made within this bucket.
        pnl_delta_native:
          type: number
          format: double
          description: PnL (native) made within this bucket.
  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.