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

# Get Profit and Loss

> Retrieve aggregate profit and loss information across all positions for a specific user.



## OpenAPI

````yaml /prediction-market-data-reference/openapi.json get /api/workflows/polymarket/getPnL
openapi: 3.1.0
info:
  title: Prediction Market Data API
  description: >-
    Comprehensive API endpoints for querying data from prediction markets
    supported via workflows.
  version: 1.0.0
  contact:
    name: Swaps.xyz
    url: https://swaps.xyz
servers:
  - url: https://api-v2.swaps.xyz
    description: Production server
security:
  - ApiKeyAuth: []
paths:
  /api/workflows/polymarket/getPnL:
    get:
      summary: Get Profit and Loss
      description: >-
        Retrieve aggregate profit and loss information across all positions for
        a specific user.
      operationId: getPnL
      parameters:
        - name: userId
          in: query
          required: true
          description: User EVM EOA address
          schema:
            $ref: '#/components/schemas/Address'
          example: '0x0797bfec6d2d4f733d461bbee8125805e9e9c892'
        - name: proxyWallet
          in: query
          description: Polymarket proxy wallet address
          schema:
            $ref: '#/components/schemas/Address'
      responses:
        '200':
          description: Profit and loss summary
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PnLResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    Address:
      type: string
      pattern: ^0x[a-fA-F0-9]{40}$
      description: EVM address (0x prefix + 40 hex characters)
      example: '0x1234567890123456789012345678901234567890'
    PnLResponse:
      type: object
      required:
        - currentPositions
        - closedPositions
        - allTime
      properties:
        currentPositions:
          type: number
          format: float
          description: Total PnL from current open positions
        closedPositions:
          type: number
          format: float
          description: Total PnL from closed positions
        allTime:
          type: number
          format: float
          description: All-time total PnL
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: Error message
        code:
          type: integer
          description: Error code
        details:
          type: object
          description: Additional error details
  responses:
    BadRequest:
      description: Bad request due to missing or invalid parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Unauthorized - Invalid or missing API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    InternalServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: API key for authentication. Contact Swaps.xyz to obtain an API key.

````