Switchbar has a URL-based API. Opening a specially formatted URL will cause Switchbar to get into action, and send a link to the right browser or email client (or prompt user to pick one).
A Switchbar API URL looks like this:
switchbar://api-method/web-url. The web-url part tells Switchbar which web address it should open, and the api-method part tells Switchbar what to do with it.
Here’s a real example:
switchbar://open/https://switchbar.app. Opening that URL will tell Switchbar to prompt you to select from all of your browsers, and to open https://switchbar.app in the browser you pick.
|open||Switchbar should decide what to do based on the user’s settings.|| |
Using the API
Exactly how you trigger the API will depend on the programming tools that you are using. To get you started, here are a few examples:
- From the Terminal, or in a shell script, you can use the Choosy API via the
- From AppleScript, you can use the
set choosy_url to "switchbar://open/https://example.org" open location choosy_url
- In a browser, browser extension, or bookmarklet, you can set the window’s location:
const url = "switchbar://open/https://example.com"; window.location.href = url;
- In a Swift application using AppKit you can use
let url: URL! = URL( string: "switchbar://open/https://example.com" ) NSWorkspace.shared.open(url: url)
Choosy API Compatibility
Switchbar also supports Choosy API so it will work with Choosy browser extensions and any applications that support Choosy.