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

# Get a user portfolio by wallet address or username (public)

> Unauthenticated variant of `/users/me/portfolio`. Resolves the
target user from the required `user` query param — a wallet address
(`0x…`, any case) or a username (case-insensitive) — and returns
the same portfolio payload as the authenticated endpoint.

Private profiles return an empty paginated result. Supports the
same `marketId`, `contractMarketId`, `status`, `marketScope`,
`sortBy`, `sortOrder`, `page`, and `take` filters.

Real-time snapshots for the same filters are available on the
unauthenticated Socket.IO namespace `/portfolio-public`; see
[Portfolio WebSocket](/data-api-reference/portfolio-websocket).




## OpenAPI

````yaml /data-api-reference/openapi.yaml get /users/portfolio
openapi: 3.0.3
info:
  title: XO Data API
  description: >
    Public HTTP routes for **market discovery, portfolio reads, and related

    metadata**, served by the NestJS
    [`xo-backend`](https://github.com/xo-market/xo)

    service on the app host (`https://api-mainnet.xo.market`).


    These endpoints are intentionally separate from the CLOB orderbook REST

    surface (`openapi.yaml`). Use them to:

      * list markets and apply filters (status, category, scope, search),
      * resolve a market by numeric id, by `conditionId`/wrapper address, or
        by slug,
      * list short-horizon **Pulse** markets (e.g. BTC 5-minute windows) and
        fetch a single pulse market by on-chain address,
      * read a user's public portfolio via `GET /users/portfolio`, and
      * read **liquidity rewards** (public discovery plus Privy-authenticated
        `/me` routes).

    Real-time portfolio snapshots are delivered over the unauthenticated

    Socket.IO namespace `/portfolio-public`. See the

    [Portfolio WebSocket](/data-api-reference/portfolio-websocket) guide.


    All paths use the service `/api` global prefix. In non-production

    deployments, the full generated Swagger document is available at

    `/swagger` on the same host.


    ### Rate limits


    Data API REST routes share a budget of **100 requests per 10 seconds**

    per client IP. `/public/liquidity-rewards/*` is throttled separately

    at **30 requests per 10 seconds**.


    ### Wire conventions

      * Pagination is page-based: `page` (1-indexed) and `take` (or `limit`
        for the Pulse routes). Liquidity-rewards proxied pages use 0-indexed
        `page` and `page_size`.
      * Numeric ids are integers; `conditionId` values are `0x`-prefixed
        32-byte hex strings. Use `conditionId` as `marketId` on
        liquidity-rewards routes.
      * Volume strings are decimal (USD) or WEI-encoded (token), depending
        on the field name (`totalVolumeInUSD` vs `totalVolume`).
      * Liquidity-rewards amounts and scores are decimal **strings**.
        Catalogue/summary BFFs are camelCase; proxied maker/market-day
        payloads are snake_case.
      * Authenticated `/liquidity-rewards/*` routes require
        `Authorization: Bearer <privy_access_token>`. The
        `/public/liquidity-rewards/*` prefix does not.

    ### Market scope for market makers


    The `/markets` endpoint accepts a `marketScope` query parameter that

    maps to the on-chain `IXOMarketV1.MarketType` enum

    (`STANDARD=0`, `PULSE=1`, `CLOB=2`, `CLOB_PULSE=3`). Market makers

    integrating against the XO CLOB **should only use**:

      * `onlyClob` — `CLOB` + `CLOB_PULSE` (orderbook markets, both
        long-form and pulse).
      * `onlyClobPulse` — `CLOB_PULSE` only (BTC 5-minute pulse).

    The remaining scopes (`default`, `withClob`, `withPulse`, `onlyPulse`)

    include `STANDARD` and/or `PULSE` markets, which are **LMSR AMM**

    deployments and are not tradable through the CLOB orderbook. Ignore

    those scopes (and rows where `market.type` is `0` or `1`) for MM use.
  version: 1.0.0
  contact:
    name: XO Market
    url: https://beta.xo.market
servers:
  - url: https://api-mainnet.xo.market/api
    description: Production xo-backend (XO mainnet, chainId 3223)
security: []
tags:
  - name: Markets
    description: Market list, filtering, and per-market metadata.
  - name: Pulse Markets
    description: Short-horizon (e.g. BTC 5-minute) Pulse markets.
  - name: Portfolio
    description: Unauthenticated public portfolio reads.
  - name: Liquidity Rewards (public)
    description: |
      Unauthenticated liquidity-rewards reads under
      `/public/liquidity-rewards`. No Privy token.
  - name: Liquidity Rewards (authenticated)
    description: |
      Privy-gated liquidity-rewards reads under `/liquidity-rewards`.
      Send `Authorization: Bearer <privy_access_token>`.
externalDocs:
  description: Data API overview
  url: /data-api-reference/introduction
paths:
  /users/portfolio:
    get:
      tags:
        - Portfolio
      summary: Get a user portfolio by wallet address or username (public)
      description: |
        Unauthenticated variant of `/users/me/portfolio`. Resolves the
        target user from the required `user` query param — a wallet address
        (`0x…`, any case) or a username (case-insensitive) — and returns
        the same portfolio payload as the authenticated endpoint.

        Private profiles return an empty paginated result. Supports the
        same `marketId`, `contractMarketId`, `status`, `marketScope`,
        `sortBy`, `sortOrder`, `page`, and `take` filters.

        Real-time snapshots for the same filters are available on the
        unauthenticated Socket.IO namespace `/portfolio-public`; see
        [Portfolio WebSocket](/data-api-reference/portfolio-websocket).
      parameters:
        - in: query
          name: user
          required: true
          schema:
            type: string
          description: Wallet address (`0x…`) or username of the target user.
          example: '0x3202b94b4d90A2F5Cc1750334e177FF7Ef95560F'
        - $ref: '#/components/parameters/Page'
        - $ref: '#/components/parameters/Take'
        - in: query
          name: marketScope
          schema:
            type: string
            enum:
              - default
              - withClob
              - withPulse
              - onlyPulse
              - onlyClobPulse
              - onlyClob
            default: default
          description: |
            Filters by indexer `marketType`. Market makers on the CLOB
            typically use `onlyClob` or `onlyClobPulse`.
        - in: query
          name: status
          schema:
            type: string
            enum:
              - active
              - closed
              - all
              - resolved
            default: all
          description: Position status filter.
        - in: query
          name: marketId
          schema:
            type: integer
          description: |
            Internal market id. When set, switches to detail mode and
            paginates positions for that market only.
        - in: query
          name: contractMarketId
          schema:
            type: string
          description: On-chain market key (`0x…`) or numeric contract id.
        - in: query
          name: marketStatus
          schema:
            type: string
          description: Filter by indexer market status (e.g. `ACTIVE`).
        - in: query
          name: search
          schema:
            type: string
          description: Case-insensitive title search.
        - in: query
          name: sortBy
          schema:
            type: string
            enum:
              - pnl
              - value
              - expiry
              - createdAt
            default: createdAt
        - in: query
          name: sortOrder
          schema:
            type: string
            enum:
              - ASC
              - DESC
            default: DESC
        - in: query
          name: refresh
          schema:
            type: boolean
            default: false
          description: Bypass portfolio cache before read.
      responses:
        '200':
          description: |
            Portfolio grouped by market (default) or filtered to a single
            market. Empty for private profiles.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PortfolioPage'
        '404':
          description: User not found
        '429':
          description: Too Many Requests
components:
  parameters:
    Page:
      in: query
      name: page
      required: false
      schema:
        type: integer
        minimum: 1
        default: 1
      description: Page number (1-indexed).
    Take:
      in: query
      name: take
      required: false
      schema:
        type: integer
        minimum: 1
        maximum: 1000
        default: 10
      description: Page size for `/markets` style endpoints.
  schemas:
    PortfolioPage:
      type: object
      required:
        - data
        - meta
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/PortfolioMarketEntry'
        meta:
          $ref: '#/components/schemas/PageMeta'
    PortfolioMarketEntry:
      type: object
      description: |
        Summary-mode portfolio row. When `marketId` is omitted on the
        request, pagination applies to markets and positions are nested
        under each market object.
      properties:
        id:
          type: integer
        contractMarketId:
          type: string
        contractAddress:
          type: string
        slug:
          type: string
        title:
          type: string
        status:
          type: string
        winningOutcomeId:
          type: integer
          nullable: true
        totalStake:
          type: number
        totalPnL:
          type: number
        transactionCounts:
          type: integer
        positions:
          type: array
          items:
            $ref: '#/components/schemas/PortfolioPosition'
    PageMeta:
      type: object
      required:
        - page
        - take
        - itemCount
        - pageCount
        - hasPreviousPage
        - hasNextPage
      properties:
        page:
          type: integer
          example: 1
        take:
          type: integer
          example: 10
        itemCount:
          type: integer
          example: 137
        pageCount:
          type: integer
          example: 14
        hasPreviousPage:
          type: boolean
          example: false
        hasNextPage:
          type: boolean
          example: true
    PortfolioPosition:
      type: object
      properties:
        id:
          type: integer
        status:
          type: string
          example: Active
        shareAmount:
          type: string
          description: Share amount in micro-shares (stringified integer).
        collateralAmount:
          type: string
        entryPrice:
          type: string
        entryValue:
          type: number
        currentValue:
          type: number
        pnl:
          type: number
        pnlPercentage:
          type: number
        hasClaimed:
          type: boolean
        outcome:
          $ref: '#/components/schemas/PortfolioOutcome'
    PortfolioOutcome:
      type: object
      properties:
        title:
          type: string
          example: 'YES'
        outcomeTokenId:
          type: string
          description: Decimal U256 CTF outcome token id.
        currentPrice:
          type: string
          example: '0.55'

````