> ## 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 Closed Positions

> Retrieve closed positions (resolved markets) for a specific user.



## OpenAPI

````yaml /prediction-market-data-reference/openapi.json get /api/workflows/polymarket/getClosedPositions
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/getClosedPositions:
    get:
      summary: Get Closed Positions
      description: Retrieve closed positions (resolved markets) for a specific user.
      operationId: getClosedPositions
      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: Array of closed positions
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ClosedPosition'
        '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'
    ClosedPosition:
      type: object
      required:
        - proxyWallet
        - asset
        - conditionId
        - avgPrice
        - totalBought
        - realizedPnl
        - curPrice
        - timestamp
        - title
        - slug
        - icon
        - eventSlug
        - outcome
        - outcomeIndex
        - oppositeOutcome
        - oppositeAsset
        - endDate
      properties:
        proxyWallet:
          type: string
          description: Proxy wallet address
          pattern: ^0x[a-fA-F0-9]{40}$
          example: '0x56687bf447db6ffa42ffe2204a05edaa20f55839'
        asset:
          type: string
          description: Asset token ID
        conditionId:
          type: string
          description: Condition ID (0x-prefixed 64-hex string)
          pattern: ^0x[a-fA-F0-9]{64}$
          example: '0xdd22472e552920b8438158ea7238bfadfa4f736aa4cee91a6b86c39ead110917'
        avgPrice:
          type: number
          format: float
          description: Average purchase price
        totalBought:
          type: number
          format: float
          description: Total amount bought
        realizedPnl:
          type: number
          format: float
          description: Realized profit/loss
        curPrice:
          type: number
          format: float
          description: Current price
        timestamp:
          type: integer
          format: int64
          description: Unix timestamp
        title:
          type: string
          description: Market title
        slug:
          type: string
          description: Market slug
        icon:
          type: string
          description: Market icon URL
        eventSlug:
          type: string
          description: Event slug
        outcome:
          type: string
          description: Outcome name
        outcomeIndex:
          type: integer
          description: Outcome index
        oppositeOutcome:
          type: string
          description: Opposite outcome name
        oppositeAsset:
          type: string
          description: Opposite asset token ID
        endDate:
          type: string
          description: Market end date
    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.

````