Class: WhopSDK::Resources::Stats

Inherits:
Object
  • Object
show all
Defined in:
lib/whop_sdk/resources/stats.rb,
sig/whop_sdk/resources/stats.rbs

Overview

Stats represent aggregated activity for an account over time. They help you understand revenue, transactions, disputes, members, referrals, and advertising performance across reporting periods like days, weeks, or months.

Use the Stats API to list available metrics and their filterable properties, then retrieve time-series values for a date range.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Stats

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Stats.

Parameters:



108
109
110
# File 'lib/whop_sdk/resources/stats.rb', line 108

def initialize(client:)
  @client = client
end

Instance Method Details

#list(request_options: {}) ⇒ WhopSDK::Models::StatListResponse

Lists every metric you can query, with its unit and the properties you can filter or break it down by.

Parameters:

Returns:

See Also:



96
97
98
99
100
101
102
103
# File 'lib/whop_sdk/resources/stats.rb', line 96

def list(params = {})
  @client.request(
    method: :get,
    path: "stats",
    model: WhopSDK::Models::StatListResponse,
    options: params[:request_options]
  )
end

#retrieve(metric, from:, to:, access_level: nil, account_id: nil, ad_campaign_ids: nil, ad_group_ids: nil, ad_ids: nil, breakdown_by: nil, card_network: nil, category: nil, convert_to: nil, currency: nil, fee_type: nil, interval: nil, most_recent_action: nil, payment_method: nil, product: nil, referred_user_id: nil, segment: nil, snapshot_window: nil, source: nil, status: nil, time_zone: nil, request_options: {}) ⇒ WhopSDK::Models::StatRetrieveResponse

Some parameter documentations has been truncated, see Models::StatRetrieveParams for more details.

Retrieves a metric as a time series of points for an account over a date range.

the

A

Parameters:

  • metric (String)

    The metric to retrieve, for example net_revenue. Use GET /stats to see every met

  • from (Date)

    Start of the date range (YYYY-MM-DD).

  • to (Date)

    End of the date range (YYYY-MM-DD).

  • access_level (String)

    Filter to a single access level. Pair with breakdown_by=access_level. Available

  • account_id (String)

    The account this query concerns, for example biz_AbC123.

  • ad_campaign_ids (Array<String>)

    Ad campaign ids (adcamp_...) to scope the report to; stats are summed across

  • ad_group_ids (Array<String>)

    Ad group ids (adgrp_...) to scope the report to; stats are summed across them.

  • ad_ids (Array<String>)

    Ad ids (ad_...) to scope the report to; stats are summed across them. Available

  • breakdown_by (String)

    Split the metric out by one of its properties — each point gets a breakdown arra

  • card_network (String)

    Filter to a single card brand, for example visa. A refinement of payment_method=

  • category (String)

    Filter to a single balance-activity category, for example payments. Pair with br

  • convert_to (String)

    Display currency for money metrics — every amount is converted into this ISO cur

  • currency (String)

    Filter to transactions made in this original ISO currency, for example eur — rep

  • fee_type (String)

    Filter to a single fee type. Pair with breakdown_by=fee_type to split fees by ty

  • interval (Symbol, WhopSDK::Models::StatRetrieveParams::Interval)

    How wide each point is. Defaults to day. Snapshot metrics are day-only.

  • most_recent_action (String)

    Filter to a single most-recent member action. Pair with breakdown_by=most_recent

  • payment_method (String)

    Filter to a single payment method, for example card or crypto. Available on metr

  • product (String)

    Filter to a single product (access pass id), for example prod_AbC123. Pair with

  • referred_user_id (String)

    Filter a referral metric to the businesses attributed to one person you referred

  • segment (String)

    Filter to a single wallet-balance segment, for example available. Pair with brea

  • snapshot_window (Symbol, WhopSDK::Models::StatRetrieveParams::SnapshotWindow)

    Trailing window for snapshot metrics. Only accepted by snapshot metrics (each li

  • source (String)

    Filter to a single GMV source, for example payments. Pair with breakdown_by=sour

  • status (String)

    Filter to a single membership status. Pair with breakdown_by=status. Available o

  • time_zone (String)

    IANA time zone to bucket the series in, for example America/New_York. Defaults t

  • request_options (WhopSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



74
75
76
77
78
79
80
81
82
83
84
# File 'lib/whop_sdk/resources/stats.rb', line 74

def retrieve(metric, params)
  parsed, options = WhopSDK::StatRetrieveParams.dump_request(params)
  query = WhopSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["stats/%1$s", metric],
    query: query,
    model: WhopSDK::Models::StatRetrieveResponse,
    options: options
  )
end