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

> ## Agent Instructions
> To integrate AGG, start with Quickstart: REST (https://docs.agg.market/quickstart/rest), then Order lifecycle & statuses (https://docs.agg.market/concepts/order-lifecycle).
> Track every trade until it reaches a terminal status. Before retrying a failed or timed-out call, read Errors, retries & idempotency (https://docs.agg.market/concepts/errors).
> The API reference is generated from https://docs.agg.market/openapi/openapi.json.

# Trader leaderboard

> Users of this app ranked by realizedPnl (default) or volume over an inclusive UTC day range; omit from/to for all time. rank is exact within the top 100 and null beyond. Identity fields follow the app's leaderboardIdentity setting. Pass exactly one of userId, externalId, username or walletAddress to look up a single user. realizedPnl is gross, position-level realized P&L in USD: sell proceeds against the position's average entry, plus settlement payout against entry, attributed to the order's creation day (sells) or the settlement day. It excludes venue and app fees. Positions with an unknown cost basis (imported inventory) contribute 0. History: volume and order counts are complete; P&L is complete from the deploy date, and earlier settled positions carry their lifetime P&L on their redemption day. Data refreshes every 5 minutes.



## OpenAPI

````yaml /openapi/openapi.json get /leaderboard
openapi: 3.0.2
info:
  title: AGG API
  version: 1.0.0
  description: >-
    Prediction market aggregator REST API — authentication, users, venue events,
    venue markets, orderbooks, charts, and execution workflows.
servers:
  - url: https://api.agg.market
    description: Production
security: []
tags:
  - name: Authentication
    description: Sign users in and manage their session tokens.
  - name: Markets
    description: Find events, markets and outcomes to trade.
  - name: Market Data
    description: Live orderbooks, prices, charts and scores for those markets.
  - name: Trading
    description: Quote, place, sign, track and cancel orders.
  - name: Portfolio
    description: A user's orders, positions, balances and activity.
  - name: Funding
    description: Deposit addresses, withdrawals, balance refills and fiat on-ramp.
  - name: Users
    description: The signed-in user's profile, linked accounts, KYC and venue keys.
  - name: Hosted Venue Accounts
    description: Provision, fund and withdraw from venue accounts hosted for the user.
  - name: Webhooks
    description: Configure and operate webhook delivery to your server.
  - name: Partner Admin
    description: Server-side reads across your app's users, orders and analytics.
  - name: Paper Trading
    description: Simulated accounts and orders for testing without real funds.
  - name: News
    description: News feeds linked to markets.
  - name: Correlated Markets
    description: Markets related to a given market and the effect of its resolution.
paths:
  /leaderboard:
    get:
      tags:
        - Portfolio
      summary: Trader leaderboard
      description: >-
        Users of this app ranked by realizedPnl (default) or volume over an
        inclusive UTC day range; omit from/to for all time. rank is exact within
        the top 100 and null beyond. Identity fields follow the app's
        leaderboardIdentity setting. Pass exactly one of userId, externalId,
        username or walletAddress to look up a single user. realizedPnl is
        gross, position-level realized P&L in USD: sell proceeds against the
        position's average entry, plus settlement payout against entry,
        attributed to the order's creation day (sells) or the settlement day. It
        excludes venue and app fees. Positions with an unknown cost basis
        (imported inventory) contribute 0. History: volume and order counts are
        complete; P&L is complete from the deploy date, and earlier settled
        positions carry their lifetime P&L on their redemption day. Data
        refreshes every 5 minutes.
      operationId: getLeaderboard
      parameters:
        - name: from
          in: query
          required: false
          schema:
            pattern: ^\d{4}-\d{2}-\d{2}$
            description: UTC calendar day, inclusive
            type: string
        - name: to
          in: query
          required: false
          schema:
            pattern: ^\d{4}-\d{2}-\d{2}$
            description: UTC calendar day, inclusive
            type: string
        - name: metric
          in: query
          required: false
          schema:
            type: string
            enum:
              - realizedPnl
              - volume
        - name: limit
          in: query
          required: false
          schema:
            minimum: 1
            maximum: 100
            type: integer
        - name: cursor
          in: query
          required: false
          schema:
            maxLength: 200
            type: string
        - name: userId
          in: query
          required: false
          schema:
            minLength: 1
            type: string
        - name: externalId
          in: query
          required: false
          schema:
            minLength: 1
            type: string
        - name: username
          in: query
          required: false
          schema:
            minLength: 1
            type: string
        - name: walletAddress
          in: query
          required: false
          schema:
            minLength: 1
            type: string
      responses:
        '200':
          description: '200'
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                  - nextCursor
                  - hasMore
                properties:
                  data:
                    description: This page of results.
                    type: array
                    items:
                      type: object
                      required:
                        - rank
                        - userId
                        - username
                        - avatarUrl
                        - walletAddress
                        - orders
                        - volume
                        - spent
                        - realizedPnl
                      properties:
                        rank:
                          minimum: 1
                          maximum: 100
                          description: Exact rank within the top 100; `null` beyond.
                          type: integer
                          nullable: true
                        userId:
                          description: AGG user id.
                          type: string
                        username:
                          description: Display name, per the app's identity setting.
                          type: string
                          nullable: true
                        avatarUrl:
                          description: Avatar URL.
                          type: string
                          nullable: true
                        walletAddress:
                          description: Wallet address, per the app's identity setting.
                          type: string
                          nullable: true
                        orders:
                          description: Filled orders in the range.
                          type: integer
                        volume:
                          description: >-
                            Notional of every filled order in the range, buys
                            and sells. USD, as a float.
                          type: number
                        spent:
                          description: Notional of filled buy orders only. USD, as a float.
                          type: number
                        realizedPnl:
                          description: >-
                            Realized profit or loss in the range, before venue
                            and app fees. USD, as a float.
                          type: number
                  nextCursor:
                    description: >-
                      Pass as `cursor` to fetch the next page; `null` on the
                      last page.
                    type: string
                    nullable: true
                  hasMore:
                    description: '`true` when another page exists.'
                    type: boolean
        '400':
          description: '400'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
        '401':
          description: '401'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
        '403':
          description: '403'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
        '429':
          description: '429'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitError'
          headers:
            Retry-After:
              schema:
                pattern: ^[1-9][0-9]*$
                description: Seconds to wait before another request; do not retry earlier.
                type: string
            Cache-Control:
              schema:
                type: string
                enum:
                  - private, no-store
      security:
        - appId: []
components:
  schemas:
    ErrorMessage:
      type: object
      required:
        - message
      properties:
        message:
          type: string
    RateLimitError:
      type: object
      required:
        - message
      properties:
        message:
          type: string
        statusCode:
          type: number
          enum:
            - 429
        code:
          type: string
          enum:
            - rate_limited
        retryAfter:
          minimum: 1
          description: Retry delay in seconds.
          type: integer
  securitySchemes:
    appId:
      type: apiKey
      in: header
      name: x-app-id
      description: Your application ID. Required for all app-tier and user-tier routes.

````