Skip to content

Misc API ​

English API reference for the clipboard, console, log, menu, misc, panel, system, test family.

This page is the primary owner for the namespaces listed below. Method names, parameter keys, and return fields follow the C++ RegisterApi handlers.

clipboard ​

clipboard.read ​

Reads the Windows clipboard and reports which of text, file list, and image data it currently holds.

No parameters.

Returns: {"files":[],"hasFiles":true,"hasImage":true,"hasText":true,"success":true,"text":"..."}

js
const result = await fb2k.invoke('clipboard.read');

clipboard.write ​

Replaces the clipboard contents with Unicode text.

ParameterTypeRequiredDescription
textstringYesText to place on the clipboard. An empty string fails with text is required.

Returns: {"error":"...","success":true}

js
await fb2k.invoke('clipboard.write', { text: 'copied text' });

clipboard.writeFiles ​

Places a file list on the clipboard so that Explorer and other shell targets can paste it.

ParameterTypeRequiredDescription
pathsarrayYesArray of absolute file paths. A missing, non-array, or empty value fails.

Returns: {"error":"...","fileCount":"...","success":true}

js
await fb2k.invoke('clipboard.writeFiles', { paths: ['C:\\Music\\song.flac'] });

clipboard.writeHTML ​

Writes rich text to the clipboard in HTML Format, together with a plain-text fallback.

ParameterTypeRequiredDescription
htmlstringYesHTML fragment to write. An empty string fails with html is required.
plainTextstringNoPlain-text fallback. Defaults to the html string itself.

Returns: {"error":"...","htmlWritten":"...","success":true,"textWritten":"..."}

js
await fb2k.invoke('clipboard.writeHTML', { html: '<b>Now playing</b>' });

console ​

console.error ​

Prints a message to the foobar2000 console with an ERROR marker.

Provide one of message or args. Empty payloads fail with message is required.

ParameterTypeRequiredDescription
messagestringNoOptional log text. Non-string values are serialized.
argsarrayNoOptional argument list joined with spaces when message is omitted.

Returns: {"error":"...","success":true}

js
const result = await fb2k.invoke('console.error', { message: 'failed to load artwork' });

console.log ​

Prints a message to the foobar2000 console.

Provide one of message or args. Empty payloads fail with message is required.

ParameterTypeRequiredDescription
messagestringNoOptional log text. Non-string values are serialized.
argsarrayNoOptional argument list joined with spaces when message is omitted.

Returns: {"error":"...","success":true}

js
const result = await fb2k.invoke('console.log', { message: 'track started' });

console.warn ​

Prints a message to the foobar2000 console with a WARN marker.

Provide one of message or args. Empty payloads fail with message is required.

ParameterTypeRequiredDescription
messagestringNoOptional log text. Non-string values are serialized.
argsarrayNoOptional argument list joined with spaces when message is omitted.

Returns: {"error":"...","success":true}

js
const result = await fb2k.invoke('console.warn', { args: ['retry', 3] });

log ​

log.clear ​

Truncates the component log file in the profile directory.

No parameters.

Returns: {"error":"...","success":true}

js
const result = await fb2k.invoke('log.clear');

log.read ​

Reads the tail of the component log file.

ParameterTypeRequiredDescription
linesintegerNoNumber of trailing lines to return. Defaults to 100. Negative values fail with lines must be non-negative.

Returns: {"content":"...","error":"...","lineCount":"...","lines":"...","success":true,"totalLines":"..."}

js
const { content } = await fb2k.invoke('log.read', { lines: 50 });

log.write ​

Appends a line to a log file in the profile directory.

Provide one of message or args. Empty payloads fail with message is required.

ParameterTypeRequiredDescription
messagestringNoLog text. Non-string values are serialized.
argsarrayNoArgument list joined with spaces when message is omitted.
filestringNoLeaf .log or .txt filename under the profile directory. Defaults to webview_ui.log.
levelstringNoLevel tag written in upper case before the message. Defaults to info.
appendbooleanNoAppends when true (the default); truncates the file first when false.
timestampbooleanNoPrefixes each line with a timestamp. Defaults to true.

Returns: {"error":"...","path":"...","success":true}

js
await fb2k.invoke('log.write', { message: 'panel initialized' });

Closes the active self-drawn menu overlay, if one is open.

ParameterTypeRequiredDefaultDescription
reasonstringNoapiOptional close reason passed to the overlay host; default api.

Returns: {"success":true}

js
const result = await fb2k.invoke('menu.close', { reason: 'api' });

Returns the context menu tree that foobar2000 would build for the selected context.

ParameterTypeRequiredDescription
handlesarrayNoTrack paths (optionally with a |subsong:N suffix), or { path, subsong } objects, used as the menu context. Required when mode is handles.
i18nbooleanNoTranslates item labels into displayLabel. Defaults to true.
localestringNoTranslation locale. Defaults to auto, which keeps the host's own labels.
modestringNoOne of auto, selection, playlist, nowPlaying, or handles. Defaults to auto, which is also used for any other value.
withAvailabilitybooleanNoIncludes per-submenu availability counters. Defaults to true.

Returns: {"Failed to initialize context menu":"...","error":"...","i18n":"...","items":"...","locale":"...","mode":"...","success":true,"withAvailability":"..."}

js
const { items } = await fb2k.invoke('menu.getContextMenu', { mode: 'selection' });

Returns the main menu tree, falling back to a flat command list when the host cannot build a tree.

ParameterTypeRequiredDescription
i18nbooleanNoTranslates item labels into displayLabel. Defaults to true.
localestringNoTranslation locale. Defaults to auto, which keeps the host's own labels.
rootstringNoRestricts the tree to one top-level menu, such as View. Defaults to the whole menu.
withAvailabilitybooleanNoIncludes per-submenu availability counters. Defaults to true.

Returns: {"error":"...","fallback":"...","items":[],"success":true}

js
const { items } = await fb2k.invoke('menu.getMainMenu', { root: 'View' });

Runs a context menu command against the current selection or the now playing track.

ParameterTypeRequiredDescription
commandstringYesCommand name or GUID string. An empty value fails with command is required.
subGuidstringNoNode GUID of a dynamically generated child. Without it the owning container is targeted, which runs nothing.

Returns: {"error":"...","guid":"...","itemCount":"...","executionConfirmed":true,"success":true}

executionConfirmed: false means the command was handed to the host through an entry point that returns nothing, so completion could not be observed. It only occurs for a registration that exposes no stable GUID.

js
await fb2k.invoke('menu.runContextCommand', { command: 'Playback Statistics/Rating/5' });

// A dynamic child needs the owning GUID plus its node GUID.
await fb2k.invoke('menu.runContextCommand', {
    command: '{5B69B9E3-1C7C-4C63-A9B0-1D0C0D0F0E0D}',
    subGuid: '{A222D5A9-2903-AA8C-EEAE-4B9230558B55}',
});

Runs a context menu command by the numeric id reported by menu.getContextMenu.

ParameterTypeRequiredDescription
idintegerYesCommand id from the built context menu. Missing, non-integer, or negative values fail with id is required.
modestringNoOne of selection, playlist, nowPlaying, handles, or auto. Defaults to auto, which is also used for any other value.
handlesarrayNoTrack paths (optionally with a |subsong:N suffix), or { path, subsong } objects, used as the menu context. Required when mode is handles.

Returns: {"Failed to initialize context menu":"...","error":"...","success":true}

js
await fb2k.invoke('menu.runContextCommandById', { id: 3 });

Runs a main menu command.

ParameterTypeRequiredDescription
commandstringYesGUID, leaf command name, or slash-separated path. An empty value fails with command is required.
subGuidstringNoGUID of a dynamic child command, paired with its owning command GUID. A malformed value fails with Invalid subGuid format.

Returns: {"error":"...","guid":"...","success":true}

command accepts a GUID, a leaf command name, or a slash-separated path. Prefer the GUID: it is the only form that is stable across hosts. A localized foobar2000 build reports localized command labels, so an English name or path will not resolve there.

Name and path forms are matched exactly per segment. When a name matches more than one command the call fails with MENU_MATCH_AMBIGUOUS and lists the candidates, rather than picking one.

Failure is always reported as success: false with a code:

codeMeaning
MENU_ITEM_DISABLEDCommand exists but is currently greyed out.
MENU_MATCH_AMBIGUOUSName matched several commands; see candidates.
MENU_COMMAND_NOT_FOUNDNo command matched.
js
// Preferred: address by GUID.
const result = await fb2k.invoke('menu.runMainMenuCommand', {
    command: '{11213A01-9F36-4E69-A1BB-7A72F418DE3A}',
});

// A dynamic child command needs its owning command GUID plus subGuid.
await fb2k.invoke('menu.runMainMenuCommand', {
    command: '{41D98AF1-8C4F-4F0E-8B7A-1A4B0F7B1234}',
    subGuid: '{A222D5A9-2903-AA8C-EEAE-4B9230558B55}',
});

Opens the self-drawn menu overlay and returns its id; the user's choice arrives later through the menu:select and menu:dismiss events, and rich-control value changes through menu:valueChanged.

ParameterTypeRequiredDescription
itemsarrayNoMenu rows, each with id, label, and optional type, enabled, checked, iconSvg, and nested submenu. Rich rows (nowplaying, rating, slider, segmented) report value changes through menu:valueChanged without closing the menu. Defaults to an empty menu.
xintegerNoScreen-space X anchor in pixels. Defaults to the cursor X, which is also used for negative values.
yintegerNoScreen-space Y anchor in pixels. Defaults to the cursor Y, which is also used for negative values.
windowModelstringNofullscreen (default) keeps the full-workarea overlay; contentSized uses a tight per-panel window with the DWM backdrop and system shadow. Any other value falls back to fullscreen.
cssstringNoFrontend style takeover injected into the overlay, at most 256 KiB; larger payloads are rejected before the overlay opens.
cssReplacebooleanNotrue replaces the built-in default styles instead of layering on top of them. Defaults to false.
backdropstringNoOne of acrylic (default), mica, mica-alt, or none; any other value keeps the default.
backdropDarkModebooleanNoDark tint for the DWM backdrop. Defaults to true.
closeAnimationMsintegerNoExit-animation delay before the overlay hides, clamped to 0-1000. Defaults to 0 (hide immediately).

Returns: {"error":"...","menuId":"...","success":true}

js
const { menuId } = await fb2k.invoke('menu.show', {
    items: [
        { id: 'play', label: 'Play' },
        { type: 'separator' },
        { id: 'props', label: 'Properties' },
    ],
});

Opens the native foobar2000 context menu at the current cursor position.

ParameterTypeRequiredDescription
handlesarrayNoTrack paths (optionally with a |subsong:N suffix), or { path, subsong } objects, used as the menu context. Required when mode is handles.
modestringNoOne of auto, selection, playlist, nowPlaying, or handles. Defaults to auto, which is also used for any other value.

Returns: {"error":"...","success":true}

js
await fb2k.invoke('menu.showNativePopup', { mode: 'nowPlaying' });

misc ​

misc.exit ​

Requests the foobar2000 exit command.

No parameters.

Returns: {"success":true}

js
const result = await fb2k.invoke('misc.exit');

misc.getComponentPath ​

Returns the directory the component DLL was loaded from.

No parameters.

Returns: {"path":"...","value":"..."}

js
const result = await fb2k.invoke('misc.getComponentPath');

misc.getFoobarPath ​

Returns the foobar2000 installation directory.

No parameters.

Returns: {"path":"...","value":"..."}

js
const result = await fb2k.invoke('misc.getFoobarPath');

misc.getProfilePath ​

Returns the foobar2000 profile directory.

No parameters.

Returns: {"path":"...","value":"..."}

js
const result = await fb2k.invoke('misc.getProfilePath');

misc.restart ​

Requests the foobar2000 restart command.

No parameters.

Returns: {"success":true}

js
const result = await fb2k.invoke('misc.restart');

misc.showConsole ​

Opens the foobar2000 console window.

No parameters.

Returns: {"success":true}

js
const result = await fb2k.invoke('misc.showConsole');

misc.showLibrarySearch ​

Opens the media library search window, optionally pre-filled with a query.

ParameterTypeRequiredDescription
querystringNoInitial search query. Defaults to an empty query.

Returns: {"query":"...","success":true}

js
await fb2k.invoke('misc.showLibrarySearch', { query: 'artist has Radiohead' });

misc.showPopupMessage ​

Shows a foobar2000 popup message dialog. Always reports success: true.

ParameterTypeRequiredDescription
messagestringNoMessage body. Defaults to an empty message.
msgstringNoLegacy alias, used only when message is absent. Prefer message.
titlestringNoDialog title. Defaults to Message.

Returns: {"success":true}

js
await fb2k.invoke('misc.showPopupMessage', {
    message: 'Playlist exported.',
    title: 'Now Playing',
});

Owner-family behavior and limits ​

  • clipboard.writeFiles accepts media-read-authorized paths. clipboard.writeHTML writes HTML plus a plain-text fallback; clipboard.read reports only formats currently available from the Windows clipboard.
  • console.log, console.warn, console.error, and log.write require one of message or args. log.write.file, when accepted, is only a leaf .log or .txt filename under the profile directory; paths, traversal and Windows reserved device names are rejected by the runtime.
  • menu.getContextMenu, menu.runContextCommandById, and menu.showNativePopup use mode to select handles, nowPlaying, selection, or playlist context. auto tries those sources in that order, ending with playlist context. In handles mode, every path is media-access validated before a handle is created. menu.showNativePopup uses screen cursor coordinates and returns before the native menu is displayed.
  • menu.show opens the self-drawn overlay after resource validation. menu.close only closes the active overlay; menu.__* endpoints are internal and are not public APIs.
  • misc.showPopupMessage accepts message, falling back to msg, and defaults title to "Message". The restart and exit methods request the corresponding foobar2000 standard command.
  • panel.setConfig changes only its documented panel fields. system.* reports registered runtime and plugin information; test.* is diagnostic surface rather than application behavior.

misc.showPreferences ​

Opens the foobar2000 preferences dialog.

No parameters.

Returns: {"success":true}

js
const result = await fb2k.invoke('misc.showPreferences');

panel ​

panel.getConfig ​

Returns the calling panel's configuration.

No parameters.

Returns: {"config":{},"success":true}

js
const result = await fb2k.invoke('panel.getConfig');

panel.setConfig ​

Updates the calling panel's configuration. Only the fields below may be changed from JavaScript; omitted fields keep their current value.

ParameterTypeRequiredDescription
enableDragDropbooleanNoEnables drag-and-drop onto the panel.
grabFocusbooleanNoLets the panel take keyboard focus on click.
panelNamestringNoDisplay name of the panel.
transparentBackgroundbooleanNoRenders the panel with a transparent background.

Returns: {"changed":"...","error":"...","success":true}

js
await fb2k.invoke('panel.setConfig', { grabFocus: true });

system ​

system.getApiStats ​

Returns counters describing the registered API surface.

No parameters.

Returns: {"registered":"...","success":true}

js
const result = await fb2k.invoke('system.getApiStats');

system.getApisByNamespace ​

Lists the registered APIs belonging to one namespace.

ParameterTypeRequiredDescription
namespacestringYesNamespace to list, such as playback. An empty value fails with namespace is required.

Returns: JSON object from the runtime handler.

js
const apis = await fb2k.invoke('system.getApisByNamespace', { namespace: 'playback' });

system.getDPI ​

Returns the DPI and scale factor of the panel's display.

No parameters.

Returns: {"dpi":"...","scale":"..."}

js
const result = await fb2k.invoke('system.getDPI');

system.getLocale ​

Returns the current Windows user locale, language, and country.

No parameters.

Returns: {"country":"...","language":"...","locale":"..."}

js
const result = await fb2k.invoke('system.getLocale');

system.getRegisteredPlugins ​

Lists the external plugins registered with the bridge.

No parameters.

Returns: {"registered":"...","success":true}

js
const result = await fb2k.invoke('system.getRegisteredPlugins');

system.getTheme ​

Returns the Windows theme state: dark mode, accent color, and transparency.

No parameters.

Returns: {"accentColor":"...","darkMode":"...","isDark":"...","transparency":"..."}

js
const result = await fb2k.invoke('system.getTheme');

system.isPluginRegistered ​

Reports whether a plugin namespace is registered.

ParameterTypeRequiredDescription
namespacestringYesPlugin namespace to check. An empty value fails with namespace is required.

Returns: {"registered":"...","success":true}

js
const { registered } = await fb2k.invoke('system.isPluginRegistered', { namespace: 'myplugin' });

system.listAvailableApis ​

Lists every API currently available through the bridge.

ParameterTypeRequiredDescription
includeExternalbooleanNoIncludes APIs registered by external plugins. Defaults to true.
includeInternalbooleanNoIncludes APIs built into the component. Defaults to true.

Returns: JSON object from the runtime handler.

js
const apis = await fb2k.invoke('system.listAvailableApis', { includeExternal: false });

system.searchApis ​

Searches registered APIs by name or description.

ParameterTypeRequiredDescription
querystringYesSearch text. An empty value fails with query is required.

Returns: JSON object from the runtime handler.

js
const apis = await fb2k.invoke('system.searchApis', { query: 'playlist' });

test ​

test.echo ​

Echoes the request back, for round-trip diagnostics.

ParameterTypeRequiredDescription
messagejsonNoAny JSON value, returned in echo. When omitted, the whole params object is echoed instead.

Returns: {"echo":"...","input":"...","success":true}

js
const { echo } = await fb2k.invoke('test.echo', { message: 'ping' });

test.ping ​

Returns a liveness marker and the host's current Unix timestamp.

No parameters.

Returns: {"pong":"...","timestamp":"..."}

js
const result = await fb2k.invoke('test.ping');

Contract supplements ​

The sections below close public-contract findings from the strict parameter audit without replacing existing explanations.

Contract supplement: log.write ​

ParameterTypeRequiredDefaultDescription
messagestringNoomittedLog text. Non-string values are serialized.
argsarrayNo[]Argument list joined with spaces when message is omitted.
filestringNoomittedLeaf .log or .txt filename under the profile directory.
levelstringNoinfoLevel tag written in upper case before the message.
appendbooleanNotrueAppends when true; truncates the file first when false.
timestampbooleanNotruePrefixes each line with a timestamp.

Return fields ​

FieldTypeOptional
errorstringYes
successbooleanNo
pathjsonNo

Semantics: omitted optional parameters use handler defaults. One of message or args must be present.

js
await fb2k.invoke('log.write', { message: 'startup complete', level: 'warn' });

Contract supplement: menu.getContextMenu ​

ParameterTypeRequiredDefaultDescription
handlesarrayNo[]Track paths, or { path, subsong } objects, used as the menu context.
i18nbooleanNotrueTranslates item labels into displayLabel.
localestringNoautoTranslation locale; auto keeps the host's own labels.
modestringNoautoOne of auto, selection, playlist, nowPlaying, or handles.
withAvailabilitybooleanNotrueIncludes per-submenu availability counters.

Return fields ​

FieldTypeOptional
errorstringYes
successbooleanNo
i18njsonNo
itemsjsonNo
localejsonNo
modejsonNo
withAvailabilityjsonNo

Semantics: omitted optional parameters use handler defaults. mode: 'handles' additionally requires a non-empty handles array.

js
const { items } = await fb2k.invoke('menu.getContextMenu', { mode: 'nowPlaying' });

Contract supplement: menu.runContextCommandById ​

ParameterTypeRequiredDefaultDescription
idintegerYes—Command id from the built context menu. Missing, non-integer, or negative values fail with id is required.
modestringNoautoOne of selection, playlist, nowPlaying, handles, or auto.
handlesarrayNo[]Track paths, or { path, subsong } objects, used as the menu context.

Return fields ​

FieldTypeOptional
errorstringYes
successbooleanNo

Semantics: omitted optional parameters use handler defaults. mode: 'handles' additionally requires a non-empty handles array.

js
await fb2k.invoke('menu.runContextCommandById', { id: 3, mode: 'selection' });

Contract supplement: misc.showPopupMessage ​

ParameterTypeRequiredDefaultDescription
messagestringNo``Message body.
msgstringNo``Legacy alias, used only when message is absent.
titlestringNoMessageDialog title.

Return fields ​

FieldTypeOptional
successbooleanNo

Semantics: omitted optional parameters use handler defaults. There is no failure branch; the call always reports success: true.

js
await fb2k.invoke('misc.showPopupMessage', { message: 'Export finished.' });