Welcome to Alfred-PyWorkflow

https://github.com/harrtho/alfred-pyworkflow/workflows/CI/badge.svg https://coveralls.io/repos/github/harrtho/alfred-pyworkflow/badge.svg?branch=main https://img.shields.io/pypi/status/Alfred-PyWorkflow.svg?style=flat https://img.shields.io/pypi/v/Alfred-PyWorkflow.svg?style=flat https://img.shields.io/pypi/pyversions/Alfred-PyWorkflow.svg?style=flat

Go to Quick Index.

Alfred-PyWorkflow is a Python helper library for Alfred 4 and 5 workflow authors, developed and hosted on GitHub.

Alfred workflows typically take user input, fetch data from the Web or elsewhere, filter them and display results to the user. Alfred-PyWorkflow takes care of a lot of the details for you, allowing you to concentrate your efforts on your workflow’s functionality.

Alfred-PyWorkflow supports macOS 10.7+ (Python 3.7).

Features

Alfred 3+ features

Quick example

Here’s how to show recent Pinboard.in posts in Alfred.

Create a new workflow in Alfred’s preferences. Add a Script Filter with Language /usr/bin/python3 and paste the following into the Script box (changing API_KEY):

 1import sys
 2from workflow import Workflow, ICON_WEB, web
 3
 4API_KEY = 'your-pinboard-api-key'
 5
 6def main(wf):
 7    url = 'https://api.pinboard.in/v1/posts/recent'
 8    params = dict(auth_token=API_KEY, count=20, format='json')
 9    r = web.get(url, params)
10    r.raise_for_status()
11    for post in r.json()['posts']:
12        wf.add_item(post['description'], post['href'], arg=post['href'],
13                    uid=post['hash'], valid=True, icon=ICON_WEB)
14    wf.send_feedback()
15
16
17if __name__ == u"__main__":
18    wf = Workflow()
19    sys.exit(wf.run(main))

Add an Open URL action to your workflow with {query} as the URL, connect your Script Filter to it, and you can now hit ENTER on a Pinboard item in Alfred to open it in your browser.

Warning

Using the above example code as a workflow will likely get you banned by the Pinboard API. See the Tutorial if you want to build an API terms-compliant (and super-fast) Pinboard workflow.

Using Alfred-PyWorkflow

Miscellaneous