Last active
August 27, 2018 10:13
-
-
Save petja/a6ccd58aac2a3887d5c707b60c3a1614 to your computer and use it in GitHub Desktop.
π² Check the status of HSL citybike station
This file contains hidden or 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 | |
# config | |
endpoint="https://api.digitransit.fi/routing/v1/routers/hsl/index/graphql" | |
querydata='{"query":"query {\n duunipaikka: bikeRentalStation(id: \"719\") {\n \tname\n bikesAvailable\n spacesAvailable\n }\n asema: bikeRentalStation(id: \"729\") {\n \tname\n bikesAvailable\n spacesAvailable\n }\n}","variables":{"id_0":"719"}}' | |
bold=$(tput bold) | |
normal=$(tput sgr0) | |
while true | |
do | |
clear | |
printf "${bold}Status checked at:${normal}\n$(date)\n\n" | |
curl \ | |
-X POST \ | |
-s $endpoint \ | |
-H 'content-type: application/json' \ | |
-d "$querydata" \ | |
| python -m json.tool | |
sleep 60 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment