Retrieve the real-time status of Paris Velib
bike stations (Bikes and stands availability).
- Gems :
- httparty
- json
- Velib API
key
previously retrieved from https://developer.jcdecaux.com/ (Account creation required) - ID of the station(s) (station number found by parsing the link below)
Add this to your erb
dashboard file (You have to replace {STATION_ALIAS}
by the alias of your choice, this alias will be reused) :
<!-- Velib {STATION_ALIAS} station-->
<li data-row="1" data-col="1" data-sizex="4" data-sizey="3">
<div data-id="velib-{STATION_ALIAS}" data-title="" data-view="Velib"></div>
</li>
You have to add this kind of block for each station you want to retrieve the status.
You have to declare your API Key (In my case, I prefer to use an environment variable) :
API_KEY = ENV["VELIB_API_KEY"]
You can retrive multiple stations datas by adding them to the following array the key
should be the STATION_ALIAS
and the value
should be the ID
of the station(s) :
stations = {
'victoire' => '9111', # Replace this by the station you want to retrieve
}
- Just copy
velib.coffee
,velib.html
andvelib.scss
to {DASHING_PATH}/widgets/velib/ - Put the
bike.svg
to {DASHING_PATH}/assets/images/
Thanks to @stephenyeargin for the inspiration with his B-Cycle widget.
API Documentation here.
Your widget don't work, unauthorized is write on launch.... :(