Para desarrolladores

API de Switchbar

Switchbar tiene una API basada en URL. Abre una URL con un formato especial y Switchbar entra en acción — enviando un enlace al navegador o cliente de correo adecuado, o pidiéndote que elijas uno.

Cómo funciona

switchbar://open/<link>
  • Enlaces web y de correo

    Pasa cualquier enlace https://, http:// o mailto:.

  • Se aplican tus reglas

    El enlace pasa por tus reglas y ajustes de enlaces, igual que un clic. Si ninguna regla coincide, Switchbar te pregunta dónde abrirlo.

  • Sin codificación

    Añade el enlace tal cual después de switchbar://open/, sin codificarlo.

Ejemplos

Terminal

# macOS
open "switchbar://open/https://example.com"
open "switchbar://open/mailto:hello@example.com"

# Windows
start "" "switchbar://open/https://example.com"

AppleScript

open location "switchbar://open/https://example.com"

JavaScript

window.location.href = "switchbar://open/https://example.com";

Swift

let url = URL(string: "switchbar://open/https://example.com")!
NSWorkspace.shared.open(url)

Compatible con URL de Choosy

Switchbar también abre enlaces de la API de Choosy, así que los scripts y herramientas creados para Choosy funcionan sin cambios.

x-choosy://open/
x-choosy://prompt.all/
x-choosy://prompt.running/
x-choosy://best.all/
x-choosy://best.running/