Last active
March 30, 2021 05:03
-
-
Save speedplane/130be6833195a31d493d2c37f91a6b00 to your computer and use it in GitHub Desktop.
New York Vaccine Alert Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# New York Vaccine Finder | |
# | |
# New York kindly provides a nice API to check for vaccine providers. But you need | |
# to constantly refresh their website. This script will check for you and will print | |
# out a message when it finds one. | |
# | |
# This script requires bash and jq to run. | |
# Find me at twitter.com/speedplane | |
# All code released freely under the MIT License. | |
# The main website that lists open locations. | |
NY_URL="https://am-i-eligible.covid19vaccine.health.ny.gov/" | |
# The API endpoint to hit. | |
NY_API_URL="$NY_URL/api/list-providers" | |
# Locations to search, pick any 3. | |
LOCATION1="New York, NY" | |
LOCATION2="Bronx, NY" | |
LOCATION3="Jamaica, NY" | |
# How often to refresh, in seconds. | |
CHECK_EVERY=30 | |
# And the rest is the code... | |
for i in `seq 1 1000`; do | |
FOUND_VAX=$(curl -s $NY_API_URL | | |
jq "[.providerList[] | | |
{name: .providerName, location: .address, has: .availableAppointments}] | | |
.[] | | |
select(.has == \"Y\" and ( | |
.location == \"$LOCATION1\" or | |
.location == \"$LOCATION2\" or | |
.location == \"$LOCATION3\") | |
)") | |
# Trim whitespace | |
FOUND_VAX_TRIM=$(echo $FOUND_VAX | xargs) | |
CUR_TIME=$(date) | |
if [ -z "$FOUND_VAX_TRIM" ]; then | |
echo "$CUR_TIME - Check $i: No NY vax." | |
sleep $CHECK_EVERY | |
else | |
echo "$CUR_TIME - FOUND_VAX: $FOUND_VAX" | |
echo "$CUR_TIME\n$FOUND_VAX:" >> found_ny-vax.txt | |
fi | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment