Class: ElevenlabsClient::Admin::History

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ History

Returns a new instance of History.



8
9
10
# File 'lib/elevenlabs_client/endpoints/admin/history.rb', line 8

def initialize(client)
  @client = client
end

Instance Method Details

#delete(history_item_id) ⇒ Hash Also known as: delete_history_item

DELETE /v1/history/:history_item_id Delete a history item by its ID Documentation: https://elevenlabs.io/docs/api-reference/history/delete-history-item

Parameters:

  • history_item_id (String)

    ID of the history item to delete

Returns:

  • (Hash)

    Status response



60
61
62
63
# File 'lib/elevenlabs_client/endpoints/admin/history.rb', line 60

def delete(history_item_id)
  endpoint = "/v1/history/#{history_item_id}"
  @client.delete(endpoint)
end

#download(history_item_ids, **options) ⇒ String Also known as: download_history_items

POST /v1/history/download Download one or more history items Documentation: https://elevenlabs.io/docs/api-reference/history/download-history-items

Parameters:

  • history_item_ids (Array<String>)

    List of history item IDs to download

  • options (Hash)

    Optional parameters

Options Hash (**options):

  • :output_format (String)

    Output format ("wav" or "default")

Returns:

  • (String)

    The binary audio data (single file) or zip file (multiple files)



84
85
86
87
88
89
90
91
92
# File 'lib/elevenlabs_client/endpoints/admin/history.rb', line 84

def download(history_item_ids, **options)
  endpoint = "/v1/history/download"
  request_body = { history_item_ids: history_item_ids }
  
  # Add optional parameters
  request_body[:output_format] = options[:output_format] if options[:output_format]

  @client.post_binary(endpoint, request_body)
end

#get(history_item_id) ⇒ Hash Also known as: get_history_item

GET /v1/history/:history_item_id Retrieves a history item by ID Documentation: https://elevenlabs.io/docs/api-reference/history/get-history-item

Parameters:

  • history_item_id (String)

    ID of the history item

Returns:

  • (Hash)

    The history item data



49
50
51
52
# File 'lib/elevenlabs_client/endpoints/admin/history.rb', line 49

def get(history_item_id)
  endpoint = "/v1/history/#{history_item_id}"
  @client.get(endpoint)
end

#get_audio(history_item_id) ⇒ String Also known as: get_audio_from_history_item

GET /v1/history/:history_item_id/audio Returns the audio of a history item Documentation: https://elevenlabs.io/docs/api-reference/history/get-audio-from-history-item

Parameters:

  • history_item_id (String)

    ID of the history item

Returns:

  • (String)

    The binary audio data



71
72
73
74
# File 'lib/elevenlabs_client/endpoints/admin/history.rb', line 71

def get_audio(history_item_id)
  endpoint = "/v1/history/#{history_item_id}/audio"
  @client.get_binary(endpoint)
end

#list(**options) ⇒ Hash Also known as: get_generated_items

GET /v1/history Returns a list of your generated audio Documentation: https://elevenlabs.io/docs/api-reference/history/get-generated-items

Parameters:

  • options (Hash)

    Optional parameters

Options Hash (**options):

  • :page_size (Integer)

    How many history items to return at maximum (max 1000, default 100)

  • :start_after_history_item_id (String)

    After which ID to start fetching (for pagination)

  • :voice_id (String)

    ID of the voice to filter for

  • :search (String)

    Search term for filtering history items

  • :source (String)

    Source of the generated history item ("TTS" or "STS")

Returns:

  • (Hash)

    Response containing history items, pagination info



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/elevenlabs_client/endpoints/admin/history.rb', line 23

def list(**options)
  endpoint = "/v1/history"

  # Build query parameters
  query_params = {}
  query_params[:page_size] = options[:page_size] if options[:page_size]
  query_params[:start_after_history_item_id] = options[:start_after_history_item_id] if options[:start_after_history_item_id]
  query_params[:voice_id] = options[:voice_id] if options[:voice_id]
  query_params[:search] = options[:search] if options[:search]
  query_params[:source] = options[:source] if options[:source]
  
  # Add query parameters to endpoint if any exist
  if query_params.any?
    query_string = query_params.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join("&")
    endpoint += "?#{query_string}"
  end

  @client.get(endpoint)
end