API Reference

Complete API documentation for frontend integration

Yap exposes Go methods to the React frontend via Wails bindings. This reference documents all available methods.

State Management

GetState

Get the current application state.

import { GetState } from '../wailsjs/go/main/App';

const state = await GetState();

Returns: AppState

interface AppState {
  state: 'ready' | 'recording' | 'transcribing' | 'error';
  recordingTime: number;    // Duration in seconds
  lastTranscript: string;   // Most recent transcription
  error: string;            // Error message if state is 'error'
  currentModel: string;     // Active model name
  currentProvider: string;  // 'local' or 'openai'
  modelReady: boolean;      // Whether model is ready
  hotkeyEnabled: boolean;   // Whether hotkey is active
}

Recording

ToggleRecording

Start or stop recording based on current state.

import { ToggleRecording } from '../wailsjs/go/main/App';

await ToggleRecording();

Returns: void | throws on error

StartRecording

Explicitly start recording.

import { StartRecording } from '../wailsjs/go/main/App';

await StartRecording();

Returns: void | throws on error

StopRecording

Stop recording and begin transcription.

import { StopRecording } from '../wailsjs/go/main/App';

await StopRecording();

Returns: void | throws on error

CancelRecording

Cancel recording without transcribing.

import { CancelRecording } from '../wailsjs/go/main/App';

await CancelRecording();

Returns: void | throws on error

History

GetHistory

Get all transcription history items.

import { GetHistory } from '../wailsjs/go/main/App';

const history = await GetHistory();

Returns: HistoryItem[]

interface HistoryItem {
  id: string;
  text: string;
  timestamp: string;
  duration: number;
  audioPath?: string;
  hasAudio: boolean;
}

ClearHistory

Delete all history items.

import { ClearHistory } from '../wailsjs/go/main/App';

await ClearHistory();

CopyHistoryItem

Copy a history item’s text to clipboard.

import { CopyHistoryItem } from '../wailsjs/go/main/App';

await CopyHistoryItem(id);

Parameters:

  • id: string — History item ID

DeleteHistoryItem

Delete a specific history item.

import { DeleteHistoryItem } from '../wailsjs/go/main/App';

await DeleteHistoryItem(id);

Parameters:

  • id: string — History item ID

GetAudioData

Get audio data as base64 for playback.

import { GetAudioData } from '../wailsjs/go/main/App';

const base64Audio = await GetAudioData(id);

Parameters:

  • id: string — History item ID

Returns: string — Base64-encoded WAV audio

ShowInFolder

Open Finder/Explorer to the audio file.

import { ShowInFolder } from '../wailsjs/go/main/App';

await ShowInFolder(id);

Parameters:

  • id: string — History item ID

Models

GetModels

Get all available Whisper models.

import { GetModels } from '../wailsjs/go/main/App';

const models = await GetModels();

Returns: ModelInfo[]

interface ModelInfo {
  name: string;        // e.g., "base.en"
  displayName: string; // e.g., "Base (English)"
  size: string;        // e.g., "~150 MB"
  downloaded: boolean;
  englishOnly: boolean;
}

SetModel

Set the active model.

import { SetModel } from '../wailsjs/go/main/App';

await SetModel('base.en');

Parameters:

  • model: string — Model name

DownloadModel

Download a model from HuggingFace.

import { DownloadModel } from '../wailsjs/go/main/App';

await DownloadModel('small.en');

Parameters:

  • model: string — Model name to download

Events emitted:

  • downloadProgress — Progress updates
  • downloadComplete — Download finished
  • downloadError — Download failed

IsModelDownloaded

Check if a model is downloaded.

import { IsModelDownloaded } from '../wailsjs/go/main/App';

const downloaded = await IsModelDownloaded('base.en');

Parameters:

  • model: string — Model name

Returns: boolean

Configuration

GetConfig

Get current configuration.

import { GetConfig } from '../wailsjs/go/main/App';

const config = await GetConfig();

Returns: Config

interface Config {
  provider: string;
  model: string;
  openaiApiKey: string;
  audioInputDevice: string;
  autoPaste: boolean;
  showNotification: boolean;
  recordingHotkey: string;
  soundEnabled: boolean;
}

SetProvider

Set transcription provider.

import { SetProvider } from '../wailsjs/go/main/App';

await SetProvider('local'); // or 'openai'

SetOpenAIKey

Set OpenAI API key.

import { SetOpenAIKey } from '../wailsjs/go/main/App';

await SetOpenAIKey('sk-...');

SetAutoPaste

Enable/disable auto-paste.

import { SetAutoPaste } from '../wailsjs/go/main/App';

await SetAutoPaste(true);

SetSoundEnabled

Enable/disable sound feedback.

import { SetSoundEnabled } from '../wailsjs/go/main/App';

await SetSoundEnabled(true);

SetRecordingHotkey

Set the recording hotkey type.

import { SetRecordingHotkey } from '../wailsjs/go/main/App';

await SetRecordingHotkey('rightOption');

Valid values: 'rightOption', 'leftOption', 'fn', 'doubleTapRightOption'

GetRecordingHotkey

Get current hotkey type.

import { GetRecordingHotkey } from '../wailsjs/go/main/App';

const hotkey = await GetRecordingHotkey();

Audio

GetAudioInputDevices

List available audio input devices.

import { GetAudioInputDevices } from '../wailsjs/go/main/App';

const devices = await GetAudioInputDevices();

Returns: AudioInputDevice[]

interface AudioInputDevice {
  name: string;
  isDefault: boolean;
}

SetAudioInputDevice

Set the audio input device.

import { SetAudioInputDevice } from '../wailsjs/go/main/App';

await SetAudioInputDevice('MacBook Pro Microphone');

GetCurrentAudioInputDevice

Get currently selected device name.

import { GetCurrentAudioInputDevice } from '../wailsjs/go/main/App';

const device = await GetCurrentAudioInputDevice();

Statistics

GetStats

Get usage statistics.

import { GetStats } from '../wailsjs/go/main/App';

const stats = await GetStats();

Returns: UsageStats

interface UsageStats {
  averageWPM: number;
  wordsThisWeek: number;
  recordingsThisWeek: number;
  timeSavedThisWeek: number;  // minutes
  totalRecordings: number;
  totalWords: number;
}

Window Management

ShowWindow

Show and focus the app window.

import { ShowWindow } from '../wailsjs/go/main/App';

await ShowWindow();

Hide

Hide the app window.

import { Hide } from '../wailsjs/go/main/App';

await Hide();

Minimize

Minimize the app window.

import { Minimize } from '../wailsjs/go/main/App';

await Minimize();

Quit

Quit the application.

import { Quit } from '../wailsjs/go/main/App';

await Quit();

Events

The app emits events to the frontend using Wails runtime events.

stateChanged

Emitted when app state changes.

import { Events } from '@wailsjs/runtime';

Events.On('stateChanged', (state: AppState) => {
  console.log('State changed:', state);
});

historyChanged

Emitted when history is updated.

Events.On('historyChanged', () => {
  // Refresh history
  const history = await GetHistory();
});

downloadProgress

Emitted during model download.

Events.On('downloadProgress', (progress: number) => {
  console.log(`Download: ${progress}%`);
});

downloadComplete

Emitted when model download finishes.

Events.On('downloadComplete', (model: string) => {
  console.log(`Downloaded: ${model}`);
});

downloadError

Emitted on download failure.

Events.On('downloadError', (error: string) => {
  console.error('Download failed:', error);
});