Make use of a dataset from opendata.paris.fr (Vélib' - Disponibilité temps réel), that is updated every minute, and describes the status of every Vélib' station.
get-records.sh
pulls the data from the API.
No need to create an account, the quota for an anonymous access is limited to 5000 queries a day, which is enough for this use case. (5000 queries/day == 3 queries/minute)
What I did was putting get-records.sh
in a crontab to be executed every minute and 20 seconds. In case the data wasn't available at this time, I put a second cron entry 30 seconds later. The script make sure that it doesn't pull the same data twice in a row.
Here's a trick to get around the minute-resolution of crontab (credits) :
* * * * * sleep 20 ; ~/velib/get-records.sh >> ~/velib/velib.log 2>&1
* * * * * sleep 50 ; ~/velib/get-records.sh >> ~/velib/velib.log 2>&1
datasource.py
was created to serve datapoints by acting as a datasource for Grafana. Note: this has not been tested since 2019.
velib.py
is a one-file-fits-all script that provides functions to generate static and animated charts based on the data available.
This is in a draft state for now and could be greatly improved.
Uses Cartopy, which depends on geos and proj. On archlinux: sudo pacman -S geos proj
and also Cython (pip)
Proj
version error: see SciTools/cartopy#1289 (comment)
Let's target cartopy@23e31dd
to get the compatibility with proj >= 6
Cartopy
requirements needs to be specified as: git+https://github.com/SciTools/cartopy.git@23e31dd#egg=Cartopy