Zapier as quantification bot

Quantification bot

I’ve liked quantification for a long time. I track keystrokes, runs, and many other little datapoints. For a long time, I’ve wanted a system that would run on a schedule, grabbing momentary data and storing it somewhere I could analyze trends over time. Zapier became that system.

Zapier is a freeform service that lets you wire together different parts of the internet. It’s very similar to IFTTT, but focusing more on power than ease of use. Zapier has quietly introduced the building blocks necessary to piece together a reliable information-gathering system, and it’s awesome.

My workflow is this:

  1. Schedule: runs a task every hour or day
  2. Code: runs Python or JavaScript code
  3. Google Sheets

You can use Node.js in the ‘Code’ step, but I didn’t: there’s no advantage to the step being asynchronous, and Python’s Requests library is unquestionably world-class. Here’s the content of my code step:

query = 'is:open is:issue author:tmcw'
token = '<a github token>'
params = { 'q': query, 'access_token': token }
response = requests.get('https://api.github.com/search/issues', params=params)
response.raise_for_status()
output = { 'count': response.json()['total_count'] }

There’s some magic in this code: output automatically becomes the input of the next step, and the requests library is automatically imported. But for the most part this is lovely simple Python code that I can test locally by adding import requests at the top and printing output to view the result.

The Google Sheets step then creates a row in a spreadsheet, and I can get my number of active GitHub issues, row-by-row

And, in the next tab, a chart of my progress:

I do the same for a few other indicators and use this system to track my progress. It updates daily, both in a spreadsheet I can easily export to CSV, and on a chart that updates automatically.

It ‘just works’: kudos to the folks at Zapier.

Posted Sep 18, 2016 Tweet / Follow me on Twitter

Tom MacWright

I'm . I work on tools for creativity at Mapbox. This is where I write about technology and everything else.