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

# Top Traders

> The market's best traders by PnL: one row per wallet and outcome, closed positions included. Unresolved, rows rank by realized PnL, then by the open position at your `marks`. Resolved, by realized plus the payout of what is still held.



## OpenAPI

````yaml /openapi.json get /v1/markets/{conditionId}/top-traders
openapi: 3.1.0
info:
  title: Codex API
  version: 1.0.0
  description: >-
    Nomos's Polymarket index, rebuilt from Polygon: holders, positions, PnL,
    trades, leaderboards and live fills.
servers:
  - url: https://codex-api.nomos.trade
security:
  - bearerAuth: []
tags:
  - name: Markets
  - name: Wallets
  - name: Leaderboard
  - name: Events
  - name: Fills
  - name: Crypto Strikes
  - name: Health
paths:
  /v1/markets/{conditionId}/top-traders:
    get:
      tags:
        - Markets
      summary: Top Traders
      description: >-
        The market's best traders by PnL: one row per wallet and outcome, closed
        positions included. Unresolved, rows rank by realized PnL, then by the
        open position at your `marks`. Resolved, by realized plus the payout of
        what is still held.
      operationId: top-traders
      parameters:
        - name: conditionId
          in: path
          required: true
          description: 'The market: 0x and 64 hex.'
          schema:
            type: string
            pattern: ^0x[0-9a-fA-F]{64}$
          example: '0x8db33416a2d1ebde7438c80129e898f89a5deb3852ca64b37c4bf46513204409'
        - name: limit
          in: query
          required: false
          description: Rows, 1 to 500. Out of range is clamped.
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          example: 5
        - name: marks
          in: query
          required: false
          description: >-
            Live prices by token, to value open positions:
            `<tokenId>:<price>,…`. Left out, open positions rank by realized PnL
            only. Ignored once resolved.
          schema:
            type: string
      responses:
        '200':
          description: OK
          headers:
            x-ratelimit-limit:
              description: Your rate, requests a minute.
              schema:
                type: integer
            x-ratelimit-remaining:
              description: Requests left in your bucket.
              schema:
                type: integer
          content:
            application/json:
              schema:
                type: object
                properties:
                  conditionId:
                    type: string
                    description: 'Condition id: 0x and 64 hex, lowercase.'
                  block:
                    type: integer
                    description: The finalized block the answer reflects.
                  resolved:
                    type: boolean
                    description: ''
                  rows:
                    type: array
                    items:
                      allOf:
                        - $ref: '#/components/schemas/Position'
                        - type: object
                          properties:
                            tokenId:
                              type: string
                              description: ''
                            mark:
                              type:
                                - number
                                - 'null'
                              description: The price used.
                            unrealizedPnl:
                              type:
                                - number
                                - 'null'
                              description: shares × mark − costBasis; null without a mark.
                            carriedAtCost:
                              type: boolean
                              description: Only on an open combo.
              example:
                conditionId: >-
                  0x8db33416a2d1ebde7438c80129e898f89a5deb3852ca64b37c4bf46513204409
                block: 94812402
                resolved: false
                rows:
                  - wallet: '0x56687bf447db6ffa42ffe2204a05edaa20f55839'
                    outcomeIndex: 0
                    shares: 41250.5
                    costBasis: 9487.62
                    avgPrice: 0.23
                    avgBuyPrice: 0.2291
                    realizedPnl: 1204.18
                    boughtShares: 52000
                    boughtUsd: 11913.2
                    soldShares: 10749.5
                    soldUsd: 3601.08
                    avgSellPrice: 0.335
                    splitShares: 0
                    mergedShares: 0
                    mergeUsd: 0
                    redeemedShares: 0
                    redeemUsd: 0
                    fees: 24.31
                    fills: 37
                    firstTradeAt: 1783987320
                    lastTradeAt: 1790862117
                    partialHistory: false
                    basisApprox: false
                    converted: false
                    amm: false
                    tokenId: >-
                      85254962656314962064648492774584063365849461315753521676016468731069088672
                    mark: 0.24
                    unrealizedPnl: 412.5
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                e0:
                  summary: market not indexed
                  value:
                    error: market not indexed
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  schemas:
    Position:
      type: object
      properties:
        wallet:
          type: string
          description: The wallet, lowercase.
        outcomeIndex:
          type: integer
          description: >-
            0 for the first outcome (Yes, Up), 1 for the second. -1 when the
            token is unknown.
        shares:
          type: number
          description: >-
            Balance now, in shares. Negative when the wallet held shares before
            history Codex saw.
        costBasis:
          type: number
          description: >-
            Fee-inclusive average cost of the shares held (Polymarket’s own
            method), in USD.
        avgPrice:
          type: number
          description: costBasis / shares, USD a share; 0 when none are held.
        avgBuyPrice:
          type: number
          description: Average buy price, fees aside; 0 when it never bought.
        realizedPnl:
          type: number
          description: Realized PnL, net of fees, in USD.
        boughtShares:
          type: number
          description: Shares bought on the order book.
        boughtUsd:
          type: number
          description: Paid for them, before fees, in USD.
        soldShares:
          type: number
          description: Shares sold on the order book.
        soldUsd:
          type: number
          description: Received for them, before fees, in USD.
        avgSellPrice:
          type: number
          description: Average sell price; 0 when it never sold.
        splitShares:
          type: number
          description: Shares minted by splits.
        mergedShares:
          type: number
          description: Shares burned by merges.
        mergeUsd:
          type: number
          description: Collateral merges returned, in USD.
        redeemedShares:
          type: number
          description: Shares redeemed after resolution.
        redeemUsd:
          type: number
          description: Their payout, in USD.
        fees:
          type: number
          description: Fees paid, in USD.
        fills:
          type: integer
          description: Order-book fills.
        firstTradeAt:
          type: integer
          description: >-
            First event of any kind on the position (trades, transfers, splits).
            Unix seconds.
        lastTradeAt:
          type: integer
          description: Latest event of any kind on the position. Unix seconds.
        partialHistory:
          type: boolean
          description: It sold, merged or redeemed more than Codex saw it acquire.
        basisApprox:
          type: boolean
          description: >-
            Transfers, conversions or neg-risk splits moved its basis by an
            approximating rule.
        converted:
          type: boolean
          description: A neg-risk conversion touched it.
        amm:
          type: boolean
          description: It traded with a 2020-22 AMM pool.
      description: One wallet's position in one outcome token.
    Error:
      type: object
      properties:
        error:
          type: string
          description: What went wrong, for a person to read.
      description: Every error answer.
  responses:
    Unauthorized:
      description: No key, or an unknown or revoked one.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: unknown or revoked API key
    RateLimited:
      description: >-
        Over your rate, or more than 4 requests (2 streams) at once. Wait
        `Retry-After` seconds.
      headers:
        retry-after:
          description: Seconds to wait.
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: 'rate limit: 600 requests a minute; retry in 1 s'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Your API key: `codex_` and 48 hex characters.'

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.