update
2017 : Now, the RATP Group is letting everyone access their realtime API : I will release a proper code and tutorial for this project ASAP.
#Paris Dashboard
π
Requirements You need an Arduino board
It's very easy to communicate
#include "TM1637Display.h"
#define CLK_TM1637 7
#define DIO_TM1637 42
TM1637Display tm1637(CLK_TM1637,DIO_TM1637);
void setup()
{
tm1637.setBrightness(0x0f);
tm1637.showNumberDec(1337,false,4,0);
}
void loop() {
}
using this library.
To communicate with my Arduino board, I use simply the screen
shell function
How it works ?
π and alerts π© in realtime π
Get RATP schedules GTFS Data
Definition from Wikipedia (en)
A GTFS feed is a collection of CSV files (with extension .txt) contained within a .zip file. Together, the related CSV tables describe a transit system's scheduled operations. The specification is designed to be sufficient to provide trip planning functionality, but is also useful for other applications such as analysis of service levels and some general performance measures. GTFS only includes scheduled operations, and does not include real-time information.
Downloads
- STIF GTFS - all the STIF schedules for 3 next weeks (70MB compressed, +500MB uncompressed)
- RATP GTFS FULL - all the annual schedules
- RATP GTFS LINES - a smaller package, divided by line
It's a little bit difficult to understand how the data is linked stops.txt
, all the stop schedules (but not the full date, just hh:mm:ss) of your station in stop_times.txt
(and all the trips)..
Parser
I recommend to use a parser to aggregate the data. I extracted them with "Node-GTFS" which contains a lot of methods to query for agencies, routes, stops and times. But you can easily find another one in another language.
Real time
To detect if an issue happened
This example will print the new tweets from TWEET_ID_RATP_LINE using TwitterAPI (python)
api = TwitterAPI(consumerKey,consumerSecret,accessToken, accessTokenSecret)
r = api.request('statuses/filter', {'follow': TWITTER_ID_RATP_LINE })
for item in r:
print(item['text'] if 'text' in item else item)
When there is a new tweet, you have to check
Those words can be found by analyzing what are the most used words by the community manager.
You can get the
tr -c '[:alnum:]' '[\n*]' < file.txt | sort | uniq -c | sort -nr | head -100
Just save a html page with a lot of tweets of one RATP line account and fire that query.
They always use the same sentences
Twitter accounts :
- RER A
- RER B
- RER C
- RER D
- RER E
- Line 1
- Line 2
- Line 3
- Line 4
- Line 5
- Line 6
- Line 7
- Line 8
- Line 9
- Line 10
- Line 11
- Line 12
- Line 13
- Line 14
- Tram 1
- Tram 2
- Tram 3A
- Tram 3B
- Tram 4 (no account)
- Tram 5
- Tram 6
- Tram 7
- Tram 8
π₯
Wap You can "grep" the RATP wap site, but it's clearly not adviced
curl --silent -A "Mozilla/5.0" "http://wap.ratp.fr/{YOURURI}" 2>&1 | grep -E -o "([0-9]+) mn"
π² in a Velib station
Get the number of available bikes You can get what you want with a simple query (edit STATIONID and KEY) :
URL_VELIB="https://api.jcdecaux.com/vls/v1/stations/{STATIONID}?contract=paris&apiKey={KEY}"
curl --silent "$URL_VELIB" 2>&1 \
| grep -E -o "\"available_bikes\":[0-9]+," | \
| awk -F ':' '{ print $2 }' | cut -d , -f1;
π
About If you have any question, open an issue.
M.Berchon invited me to introduce this project at the Β« Paris Hardware Startup Meetup #2 Β»