This picture may look simple but a lot of tech went into making it happen

Even with the increased availability of covid vaccines, in the US, the problem many of us face is the the inability to get a vaccine appointment (or know where one is available). In my state, someone made a website that scrapes a lot of local data sources and provides a central location to query appointments. I noticed that this page exposed GET call that it made via javascript. Even better what if I could poll this data myself periodically with a cron job, parse the JSON and then when send a push notification to all of my devices. The latter part is where XMPP and Monal’s APNS infrastructure comes in. A couple of hours of tinkering later, I have the following script. I’m not the best at shell scripting and jq but this does the trick. If there is an appointment in places I care about the name, location and URL are pushed to every device I own. This is probably not super useful to anyone outside of Massachusetts, but feel free to take this and point it at your own data sources. The code is on GitHub please suggest improvements if you see anything that could be better. I am not sure how many other consumer messaging systems let you script like this without hacks. You could probably use SMS with something like Twilio but that involves paying for messages.

Just for fun this is a diagram of the insane flow that makes the picture at the start of this post happen:

I use two tools you will need to install; jq to parse and query JSON and sendxmpp, a command line xmpp client. You will probably also want to set your cron tab to something that is called at an interval e.g.

*/30 * * * *

The script:

#!/bin/bash
rm *.json 
curl 'https://mzqsa4noec.execute-api.us-east-1.amazonaws.com/prod' \
  -H 'authority: mzqsa4noec.execute-api.us-east-1.amazonaws.com' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.192 Safari/537.36' \
  -H 'accept: */*' \
  -H 'origin: https://www.macovidvaccines.com' \
  -H 'sec-fetch-site: cross-site' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-dest: empty' \
  -H 'referer: https://www.macovidvaccines.com/' \
  -H 'accept-language: en-US,en;q=0.9' \
  --compressed -o data.json
  jq  ".body |fromjson | .results "  data.json  > results.json
for row in $(cat results.json | jq  -r '.[] | select(.hasAvailability==true)  | select(.name |startswith("Walgreens")) | "Available in "+ .name + "," + .city +" "+ .signUpLink  | @base64'); 
do
    message=`echo ${row} | base64 --decode `
    echo "$message" |sendxmpp <address>  -t
done
for row in $(cat results.json | jq  -r '.[] | select(.hasAvailability==true)  | select(.name |startswith("CVS")) | "Available in "+ .name + "," + .city +" "+ .signUpLink  | @base64'); 
do
    message=`echo ${row} | base64 --decode `
    echo "$message" |sendxmpp <address>  -t
done
for row in $(cat results.json | jq  -r '.[] | select(.hasAvailability==true)  | select(.name |startswith("Fenway Park")) | "Available in "+ .name + "," + .city +" "+ .signUpLink  | @base64'); 
do
    message=`echo ${row} | base64 --decode `
    echo "$message" |sendxmpp <address>  -t
done