Class: ElevenlabsClient::Admin::Usage

Inherits:
Object
  • Object
show all
Defined in:
lib/elevenlabs_client/endpoints/admin/usage.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Usage

Returns a new instance of Usage.



6
7
8
# File 'lib/elevenlabs_client/endpoints/admin/usage.rb', line 6

def initialize(client)
  @client = client
end

Instance Method Details

#get_character_stats(start_unix:, end_unix:, include_workspace_metrics: nil, breakdown_type: nil, aggregation_interval: nil, aggregation_bucket_size: nil, metric: nil) ⇒ Hash Also known as: character_stats

GET /v1/usage/character-stats Gets character usage metrics for the current user or workspace Documentation: https://elevenlabs.io/docs/api-reference/usage/get-character-stats

Parameters:

  • start_unix (Integer)

    UTC Unix timestamp for the start of the usage window (in milliseconds)

  • end_unix (Integer)

    UTC Unix timestamp for the end of the usage window (in milliseconds)

  • include_workspace_metrics (Boolean) (defaults to: nil)

    Whether to include the statistics of the entire workspace (defaults to false)

  • breakdown_type (String) (defaults to: nil)

    How to break down the information. Cannot be "user" if include_workspace_metrics is false

  • aggregation_interval (String) (defaults to: nil)

    How to aggregate usage data over time ("hour", "day", "week", "month", or "cumulative")

  • aggregation_bucket_size (Integer, nil) (defaults to: nil)

    Aggregation bucket size in seconds. Overrides the aggregation interval

  • metric (String) (defaults to: nil)

    Which metric to aggregate

Returns:

  • (Hash)

    The JSON response containing time axis and usage data



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/elevenlabs_client/endpoints/admin/usage.rb', line 22

def get_character_stats(start_unix:, end_unix:, include_workspace_metrics: nil, breakdown_type: nil, aggregation_interval: nil, aggregation_bucket_size: nil, metric: nil)
  endpoint = "/v1/usage/character-stats"
  
  params = {
    start_unix: start_unix,
    end_unix: end_unix
  }
  
  params[:include_workspace_metrics] = include_workspace_metrics unless include_workspace_metrics.nil?
  params[:breakdown_type] = breakdown_type if breakdown_type
  params[:aggregation_interval] = aggregation_interval if aggregation_interval
  params[:aggregation_bucket_size] = aggregation_bucket_size if aggregation_bucket_size
  params[:metric] = metric if metric
  
  @client.get(endpoint, params)
end