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

# Get PnL

> Get your realized profit and loss over a time period

## Authentication

Read authentication required — `X-Public-Key` header. See the [Authentication guide](/authentication).

## Query parameters

<ParamField query="timePeriod" type="string">
  Predefined time window. If omitted and no custom range is provided, defaults to all time.

  **Rolling windows:** `12H`, `24H`, `1W`, `1M`, `1Y` — relative to current time (e.g. `1M` = last 30 days).

  **Calendar windows:** `THIS_WEEK`, `THIS_MONTH`, `THIS_YEAR` — from the start of the current week/month/year to now.
</ParamField>

<ParamField query="start" type="string">
  Custom start time in ISO 8601 format. Overrides `timePeriod`. Must be paired with `end`.
</ParamField>

<ParamField query="end" type="string">
  Custom end time in ISO 8601 format. Overrides `timePeriod`. Must be paired with `start`.
</ParamField>

<ParamField query="currency" type="string">
  Currency filter — `USD` or `NGN`. Defaults to `USD` if omitted. PnL is computed per currency, so if you traded only in NGN and query USD, all values will be zero.
</ParamField>

<ParamField query="breakdown" type="boolean">
  Include per-event breakdown (top 30 events by most recent activity). Defaults to `false`.
</ParamField>

## Example request

<CodeGroup>
  ```bash cURL theme={null}
  curl "https://relay.bayse.markets/v1/pm/pnl?timePeriod=1M&breakdown=true" \
    -H "X-Public-Key: pk_live_abcdef123456"
  ```

  ```javascript Node.js theme={null}
  const response = await fetch(
    'https://relay.bayse.markets/v1/pm/pnl?timePeriod=1M&breakdown=true',
    {
      headers: {
        'X-Public-Key': 'pk_live_abcdef123456',
      },
    }
  );
  const pnl = await response.json();
  ```

  ```python Python theme={null}
  import requests

  resp = requests.get(
      'https://relay.bayse.markets/v1/pm/pnl',
      params={'timePeriod': '1M', 'breakdown': 'true'},
      headers={'X-Public-Key': 'pk_live_abcdef123456'},
  )
  pnl = resp.json()
  ```

  ```go Go theme={null}
  req, _ := http.NewRequest("GET", "https://relay.bayse.markets/v1/pm/pnl?timePeriod=1M&breakdown=true", nil)
  req.Header.Set("X-Public-Key", "pk_live_abcdef123456")
  resp, _ := http.DefaultClient.Do(req)
  ```
</CodeGroup>

## Response

<ResponseField name="realizedPnl" type="number">
  Total realized PnL — the sum of `settlementPnl` and `tradePnl`.
</ResponseField>

<ResponseField name="realizedPnlPercent" type="number">
  Realized PnL as a percentage of total cost basis. `0` when no cost basis exists in the queried period.
</ResponseField>

<ResponseField name="settlementPnl" type="number">
  PnL from resolved markets. Computed as total payouts received minus total cost basis of settled positions.
</ResponseField>

<ResponseField name="tradePnl" type="number">
  PnL from selling shares before market resolution. Computed as proceeds minus cost basis for each sell.
</ResponseField>

<ResponseField name="wins" type="integer">
  Number of settled positions that received a payout.
</ResponseField>

<ResponseField name="losses" type="integer">
  Number of settled positions that received zero payout.
</ResponseField>

<ResponseField name="currency" type="string">
  Currency the PnL is denominated in.
</ResponseField>

<ResponseField name="breakdown" type="array">
  Per-event PnL breakdown. Only present when `breakdown=true`.

  <Expandable title="breakdown item fields">
    <ResponseField name="eventId" type="string">Event UUID.</ResponseField>
    <ResponseField name="eventTitle" type="string">Title of the event.</ResponseField>
    <ResponseField name="realizedPnl" type="number">Aggregated realized PnL for this event (settlements + sells).</ResponseField>
    <ResponseField name="currency" type="string">Currency.</ResponseField>
    <ResponseField name="lastActivity" type="string">ISO 8601 timestamp of the most recent settlement or sell in this event.</ResponseField>
  </Expandable>
</ResponseField>

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "realizedPnl": 31.11,
    "realizedPnlPercent": 6.03,
    "settlementPnl": 24.50,
    "tradePnl": 6.61,
    "wins": 8,
    "losses": 6,
    "currency": "USD",
    "breakdown": [
      {
        "eventId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
        "eventTitle": "Will BTC close above $95k today?",
        "realizedPnl": 12.35,
        "currency": "USD",
        "lastActivity": "2026-03-20T14:30:00Z"
      },
      {
        "eventId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
        "eventTitle": "Will Super Eagles qualify for AFCON 2026?",
        "realizedPnl": -3.50,
        "currency": "USD",
        "lastActivity": "2026-03-19T09:15:00Z"
      }
    ]
  }
  ```
</ResponseExample>
