Skip to content

Instantly share code, notes, and snippets.

@petja
Last active August 27, 2018 10:13
Show Gist options
  • Save petja/a6ccd58aac2a3887d5c707b60c3a1614 to your computer and use it in GitHub Desktop.
Save petja/a6ccd58aac2a3887d5c707b60c3a1614 to your computer and use it in GitHub Desktop.
🚲 Check the status of HSL citybike station
#!/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