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

# Get Referral Statistics

> Returns aggregated referral performance stats for the authenticated account. All-time totals are always returned. When `interval_days` is supplied, period-scoped stats (qualified referrals, first-trade volume, period earnings, earnings breakdown) are filtered to that window.



## OpenAPI

````yaml GET /v1/accounts/referrals/stats
openapi: 3.0.3
info:
  title: Predicta Markets API
  description: >-
    The Predicta Markets REST API lets you build on top of a continuous
    double-auction prediction market platform. Users buy and sell shares in
    YES/NO outcomes of real-world events. When a market resolves, holders of the
    winning side receive payouts; holders of the losing side lose their stake.


    Data model hierarchy: Market → MarketAsset → MarketAssetOption (prediction
    key) → Order. A Market is a question about a real-world event (e.g. 'Will
    Arsenal win the Premier League?'). Each Market contains one or more
    MarketAssets — the tradeable outcomes. Simple binary markets have a single
    asset; multi-player markets (e.g. Player of the Match) have one asset per
    candidate. Each MarketAsset exposes two options, YES and NO, each carrying a
    prediction_key — the unique hash you pass when placing an order to identify
    exactly which outcome you are trading.


    Trading flow: (1) call GET /v1/markets to find a market; (2) inspect
    market_assets and their options to get the prediction_key for the outcome
    you want; (3) call POST /v1/markets/{market_id}/orders with that
    prediction_key, your price, and quantity. Orders match immediately when a
    counterparty exists, otherwise they rest as open limit orders in the order
    book.


    Price system: all prices are integers in the range 1–99, representing cents.
    Price equals implied probability in percent — a YES price of 65 means the
    market implies a 65% chance the event will occur. YES and NO prices for the
    same asset always sum to approximately 100.


    Currency: the platform's internal unit is PT (Predicta Token). Balances,
    prices, and payout amounts are expressed in PT unless the market was created
    with a real-currency denomination.


    QID system: many resources expose a human-readable qualified ID (qid)
    alongside the numeric id. QIDs are computed, not stored as database columns.
    Prefix conventions — MA: market, MAA: market asset, AP: account payout. Most
    path parameters accept either the numeric id or the qid interchangeably.


    Authentication: include your API key in the X-Api-Key request header. All
    account-scoped endpoints require authentication. Market listing and detail
    endpoints are public.
  version: 1.0.0
  contact:
    email: api-support@predictamarkets.com
servers:
  - url: https://api.predictamarkets.com
    description: Production
security: []
paths:
  /v1/accounts/referrals/stats:
    get:
      tags:
        - Referrals
      summary: Get Referral Statistics
      description: >-
        Returns aggregated referral performance stats for the authenticated
        account. All-time totals are always returned. When `interval_days` is
        supplied, period-scoped stats (qualified referrals, first-trade volume,
        period earnings, earnings breakdown) are filtered to that window.
      operationId: get_referral_stats
      parameters:
        - name: interval_days
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            example: 30
          description: Scope period-specific stats to the last N days. Omit for all-time.
      responses:
        '200':
          description: Referral stats
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReferralStatsResponse'
              example:
                referral_code: JANE42
                interval_days: 30
                total_referred: 42
                total_earnings: '126.00'
                total_visits: 310
                pending_referrals: 5
                completed_referrals: 37
                unverified_referrals: 8
                period_earnings: '45.00'
                qualified_referrals: 15
                first_trade_volume: '220.50'
                earnings_by_event_type:
                  - event_type: DEPOSIT
                    total: '33.00'
                    count: 11
                  - event_type: TRADE
                    total: '12.00'
                    count: 8
                earning_rules:
                  - id: 1
                    name: Partner deposit bonus
                    event_type: DEPOSIT
                    earn_type: FIXED
                    fixed_amount: '3.00'
                    rate: null
                    percentage_base: null
                    min_trigger_amount: '15.00'
                    max_occurrences: 1
                    is_global: false
                  - id: 2
                    name: First trade commission
                    event_type: TRADE
                    earn_type: PERCENTAGE
                    fixed_amount: null
                    rate: '0.015000'
                    percentage_base: TRANSACTION_AMOUNT
                    min_trigger_amount: null
                    max_occurrences: 1
                    is_global: false
        '401':
          description: Not authenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                detail: Not authenticated
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
        - apiKey: []
components:
  schemas:
    ReferralStatsResponse:
      type: object
      title: ReferralStatsResponse
      properties:
        referral_code:
          type: string
          nullable: true
          description: >-
            The authenticated account's referral code. Share this to earn
            commissions.
        interval_days:
          type: integer
          nullable: true
          description: >-
            The time window (in days) used for period-scoped stats. Null if
            all-time stats were requested.
        total_referred:
          type: integer
          description: >-
            All-time total number of accounts that signed up using this referral
            code.
        total_earnings:
          type: string
          example: '126.00'
          description: All-time total referral earnings credited to this account (in PT).
        total_visits:
          type: integer
          description: >-
            All-time total number of visits tracked via this referral code
            (before or without registration).
        pending_referrals:
          type: integer
          description: >-
            Referred accounts that have signed up but not yet completed the
            qualifying action (e.g. first trade or verification).
        completed_referrals:
          type: integer
          description: >-
            Referred accounts that have completed all qualifying actions and
            triggered a payout.
        unverified_referrals:
          type: integer
          description: >-
            Referred accounts that registered but have not yet verified their
            identity.
        period_earnings:
          type: string
          example: '45.00'
          description: >-
            Total earnings within the interval_days window (in PT). Null if no
            interval was specified.
        qualified_referrals:
          type: integer
          description: >-
            Number of referred accounts within the interval that met the first
            qualifying action threshold (e.g. placed their first trade).
        first_trade_volume:
          type: string
          example: '220.50'
          description: >-
            Total volume of first trades placed by referred accounts within the
            interval.
        earnings_by_event_type:
          type: array
          items:
            $ref: '#/components/schemas/EarningsByEventTypeResponse'
          description: >-
            Breakdown of period earnings grouped by the event type that
            triggered each earning (DEPOSIT, TRADE, SIGNUP, etc.).
        earning_rules:
          type: array
          items:
            $ref: '#/components/schemas/EarningRuleResponse'
          description: >-
            The active referral earning rules that apply to this account's
            program.
      required:
        - total_referred
        - total_earnings
        - total_visits
        - pending_referrals
        - completed_referrals
        - unverified_referrals
        - period_earnings
        - qualified_referrals
        - first_trade_volume
        - earnings_by_event_type
        - earning_rules
      description: >-
        Aggregated referral performance statistics for the authenticated
        account. All-time totals are always present; period-scoped stats
        (qualified_referrals, first_trade_volume, period_earnings,
        earnings_by_event_type) are filtered to the interval_days window if
        provided.
    ErrorResponse:
      type: object
      properties:
        detail:
          type: string
          description: Human-readable error message
      required:
        - detail
      title: ErrorResponse
    EarningsByEventTypeResponse:
      type: object
      title: EarningsByEventTypeResponse
      properties:
        event_type:
          type: string
        total:
          type: string
          example: '45.00'
        count:
          type: integer
      required:
        - event_type
        - total
        - count
    EarningRuleResponse:
      type: object
      title: EarningRuleResponse
      properties:
        id:
          type: integer
          description: Unique rule ID.
        name:
          type: string
          description: Human-readable name for this rule (e.g. 'Partner deposit bonus').
        event_type:
          type: string
          enum:
            - DEPOSIT
            - TRADE
            - SIGNUP
            - VERIFICATION
            - ORDER
            - WIN
          description: >-
            The qualifying event that triggers this earning rule: DEPOSIT,
            TRADE, SIGNUP, VERIFICATION, ORDER, or WIN.
        earn_type:
          type: string
          enum:
            - FIXED
            - PERCENTAGE
          description: >-
            How the earning is calculated: FIXED (a flat amount per qualifying
            event) or PERCENTAGE (a fraction of a base amount).
        fixed_amount:
          type: string
          nullable: true
          example: '3.00'
          description: >-
            Fixed PT amount earned per qualifying event. Only present when
            earn_type is FIXED.
        rate:
          type: string
          nullable: true
          example: '0.015000'
          description: >-
            Decimal rate applied to the percentage_base. Only present when
            earn_type is PERCENTAGE. For example, 0.015 means 1.5%.
        percentage_base:
          type: string
          nullable: true
          enum:
            - TRANSACTION_AMOUNT
            - PLATFORM_FEE
          description: >-
            Which amount the rate is applied to: TRANSACTION_AMOUNT (the deposit
            or trade value) or PLATFORM_FEE (the platform's fee on the
            transaction).
        min_trigger_amount:
          type: string
          nullable: true
          example: '15.00'
          description: >-
            Minimum transaction amount required for this rule to trigger. Null
            if there is no minimum.
        max_occurrences:
          type: integer
          nullable: true
          description: >-
            Maximum number of times this rule can pay out per referred account.
            Null for unlimited.
        is_global:
          type: boolean
          description: >-
            True if this rule applies to all referral programs platform-wide.
            False if it is configured only for specific HUB accounts.
      required:
        - id
        - name
        - event_type
        - earn_type
        - is_global
      description: >-
        Configuration of a single referral earning rule that applies to the
        authenticated account's referral program. Defines when and how much is
        earned per qualifying event.
  responses:
    InternalServerError:
      description: Internal Server Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            detail: An unexpected error occurred. Please try again later.
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-Api-Key
      x-default: your-api-key-here

````