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

# Get profit and loss

> Retrieve aggregated PnL (profit and loss) grouped by bookmaker, account, or userRef.

Only includes settled bets (`settlementStatus` NOT in UNSETTLED).

**Group by options:**
- `bookmaker` (default) — Group by bookmaker
- `account` — Group by bookmaker account
- `userRef` — Group by user reference

**Filters:**
- `bookmaker` — Filter to a specific bookmaker
- `userRef` — Filter to a specific user reference
- `account` — Filter to a specific account



## OpenAPI

````yaml /zh/abp-api/openapi.json get /pnl
openapi: 3.1.0
info:
  title: ABP v2 - Automated Bet Placing API
  description: >

    Place bets across 32 bookmakers through a single API.


    ## Authentication


    All endpoints require the `x-api-key` header (except `/health`, `/ready`,
    `/status`, `/metrics`).


    **Swagger UI**: Click the **Authorize** button (lock icon) at the top right,
    enter your API key, and click **Authorize**.


    ## Quick Start


    1. **List your accounts**: `GET /accounts`

    2. **Get live odds**: `GET /betslip?fixtureId=...&outcomeId=...&playerId=0`

    3. **Place an order**: `POST /place-orders`

    4. **Track results**: `GET /orders` or subscribe to WebSocket updates


    ## WebSocket


    Connect to `/ws` for real-time order, bet, and settlement updates.


    ```json

    {"type": "login", "apiKey": "your-api-key", "channels": []}

    ```


    Send an empty `channels` array to receive all updates. Available channels:
    `orders`, `bets`, `settlements`, `accounts`, `balance`, `betslip`,
    `fixtures`, `currencies`, `status`, `emergency`.


    Send `{"type": "ping"}` every 30 seconds to keep the connection alive.
  version: '2.0'
servers:
  - url: https://v2.55-tech.com
    description: Production
security:
  - apiKey: []
tags:
  - name: Orders
    description: Place, retrieve, and cancel betting orders
  - name: Bets
    description: Query individual bets placed with bookmakers
  - name: Betslip
    description: Get live odds and metadata for fixtures
  - name: Accounts
    description: Manage bookmaker accounts
  - name: Markets
    description: Get available markets and odds types
  - name: Bookmakers
    description: List supported bookmakers
  - name: Analytics
    description: Positions and profit/loss analytics
paths:
  /pnl:
    get:
      tags:
        - Analytics
      summary: Get profit and loss
      description: >-
        Retrieve aggregated PnL (profit and loss) grouped by bookmaker, account,
        or userRef.


        Only includes settled bets (`settlementStatus` NOT in UNSETTLED).


        **Group by options:**

        - `bookmaker` (default) — Group by bookmaker

        - `account` — Group by bookmaker account

        - `userRef` — Group by user reference


        **Filters:**

        - `bookmaker` — Filter to a specific bookmaker

        - `userRef` — Filter to a specific user reference

        - `account` — Filter to a specific account
      operationId: get_pnl
      parameters:
        - name: groupBy
          in: query
          required: false
          schema:
            type: string
            default: bookmaker
            enum:
              - bookmaker
              - account
              - userRef
          description: 'Group PnL by: bookmaker, account, or userRef'
        - name: bookmaker
          in: query
          required: false
          schema:
            type: string
            nullable: true
          description: Filter by bookmaker slug
        - name: userRef
          in: query
          required: false
          schema:
            type: string
            nullable: true
          description: Filter by user reference
        - name: account
          in: query
          required: false
          schema:
            type: string
            nullable: true
          description: Filter by account username
      responses:
        '200':
          description: Successfully retrieved PnL
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PnlResponse'
              example:
                status: success
                groupBy: bookmaker
                pnl:
                  - bookmaker: pinnacle
                    settledBets: 42
                    wins: 23
                    losses: 17
                    voids: 1
                    pushes: 1
                    totalStaked: 2100
                    totalWon: 2350
                    totalLost: 850
                    netPnl: 250
                    winRate: 54.8
                  - bookmaker: sharpbet
                    settledBets: 15
                    wins: 9
                    losses: 5
                    voids: 1
                    pushes: 0
                    totalStaked: 750
                    totalWon: 900
                    totalLost: 250
                    netPnl: 150
                    winRate: 60
                count: 2
                totalNetPnl: 400
                totalStaked: 2850
                totalSettledBets: 57
        '400':
          description: Invalid parameters
        '401':
          description: Unauthorized
        '503':
          description: Database unavailable
components:
  schemas:
    PnlResponse:
      type: object
      properties:
        status:
          type: string
        groupBy:
          type: string
        pnl:
          type: array
          items:
            $ref: '#/components/schemas/PnlEntry'
        count:
          type: integer
        totalNetPnl:
          type: number
        totalStaked:
          type: number
        totalSettledBets:
          type: integer
    PnlEntry:
      type: object
      properties:
        bookmaker:
          type: string
          nullable: true
        account:
          type: string
          nullable: true
        userRef:
          type: string
          nullable: true
        settledBets:
          type: integer
        wins:
          type: integer
        losses:
          type: integer
        voids:
          type: integer
        pushes:
          type: integer
        totalStaked:
          type: number
        totalWon:
          type: number
        totalLost:
          type: number
        netPnl:
          type: number
          description: Net profit/loss
        winRate:
          type: number
          nullable: true
          description: Win rate percentage
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: API key for authentication. Contact contact@55-tech.com to obtain a key.

````