Shortcuts

The Shortcuts service lists and runs the user's shortcuts from the Shortcuts app. Access it via app.shortcuts. The first run of a shortcut that uses files, the clipboard or other apps may ask the user for permission.

app.shortcuts.list()
summary = app.shortcuts.run("Summarize Text", input=article)

Methods

run(name, input=None, input_path=None, timeout=60.0)

Run a shortcut and return its output: a str for text, bytes for anything else (an image, a PDF...), or None when it outputs nothing.

Parameter Type Description
name str The shortcut's name or identifier
input str \| bytes Text or data to give the shortcut as input
input_path str \| PathLike A file to give it as input instead
timeout float Seconds to wait for it to finish

A shortcut that is missing or fails raises nib.ServiceError with the system's message.

list(folder=None)

The names of the user's shortcuts, optionally of one folder.