You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+13-7Lines changed: 13 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ CFR S.A., the Romanian national railway infrastructure administration company of
6
6
7
7
This NodeJS & ExpressJS based API controls the PhantomJS headless webkit engine to extract data from the CFR webapp as requested in the URL API Endpoint and outputs reusable JSON data.
8
8
9
-
###Installation & Requirments
9
+
## Installation & Requirments
10
10
- You need NodeJS and NPM installed on your system: [See their website for details](https://nodejs.org/en/download/). You may or may not have luck with portable versions.
11
11
- Clone the repository and install the module dependencies:
12
12
```sh
@@ -18,23 +18,29 @@ $ npm install
18
18
```sh
19
19
$ node .
20
20
```
21
-
### Usage
21
+
## Usage
22
+
### Station information
22
23
Now you can point your browser to http://localhost:9090/station/ID to see the magic. ID is the unique station-unit code, you have [a list of those in this very nice repo](https://github.com/vasile/data.gov.ro-gtfs-exporter/blob/master/cfr.webgis.ro/stops.geojson). For example, to get a JSON object with the current departure/arrival board & delay information for the Bucharest North railway station (the main & biggest one in our country), you would point your browser or the URL variable for whatever app you are consuming the data with to: http://localhost:9090/station/10017.
23
-
### Ideas
24
+
### Train information
25
+
In the same way you can get the current trains in a certain railway station, you can get the current information for a certain train. CFR provides information such as delays, the last station the train has passed (with a 7-minute delay), the next station and other useful information.
26
+
27
+
Just point your browser to http://localhost:9090/train/ID, where ID is the train's unique number. You can get these IDs from the station information feed. For example, you can retrieve the information for train IR 1651 from Bucharest North to Suceava North (valid as of April 2017) by accessing http://localhost:9090/train/1651.
28
+
29
+
## Ideas
24
30
While the official apps themselves work but may not look so great, romanian developers did their best to create some really cool open source projects and online services related to transportation and infrastructure. See [this live map](http://cfr.webgis.ro/), [this proprietary to GTFS converter](https://github.com/vasile/data.gov.ro-gtfs-exporter), [this trip planner](https://www.acceleratul.ro), etc.
25
31
26
32
Using this API and other public resources, you may create your own style of station departure board, delay-notification service, cool looking mobile app, while learning how to program and work with structured data ?
27
-
###License, disclaimer and known limitations
33
+
## License, disclaimer and known limitations
28
34
This is a completely open source project, built on open source modules and libraries and licensed under [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0.html).
29
35
30
36
Also, you are completely responsible for what you do with it - keep in mind that CFR S.A. and InfoFer (the state-railway owned IT firm which builds their software) are not particularly transparent or third party developer friendly. If you do mass-scraping or develop some publicly accessible service that generates loads of traffic from the same server to them or clones their data to a database for various reasons, you may run into some trouble, [as this fellow enthusiast did while making a web trip-planner using CFR Calatori's timetable from their website](http://legi-internet.ro/blogs/index.php/cfr-crede-ca-are-monopol-pe-mersul-trenurilor-pe-internet).
31
37
32
38
But for tinkering, playing around and working with real-time data that clearly can't confuse anyone if the error is not from CFR themselves, you should be fine and on the right side of the law, at least from my experience. Maybe they'll offer their own API with proper rules and licensing at some point.
33
39
34
-
Known limitations:
35
-
- Currently you can only get the station departure & arrival (times, originating & destination station) board with delays and lines (where applicable) through the /station/ID endpoint, while detailed information about individual trips and trips between stations is provided by the CFR webpage. I may work on additional features.
40
+
#### Known limitations:
36
41
- Requests are not authenticated and no rate limiting is implemented, so it's in no way ready to be exposed on the web.
37
42
- This is not particularly fast, because the CFR Webpage isn't either. You'll probably want background requests and caching. After the initial request is made, it'll wait 8 seconds before parsing the data. If data hasn't been displayed on the webpage, it will wait an additional 20 seconds. After this, the API will output a blank object - this may mean that the scraped web service is down, it is really slow to respond or there are really no current trips stopping at that particular station (at night or at a small stop, for example).
38
43
- This is scraping and parsing, so any structural update to the CFR webpage, while highly unlikely in the near future may break this.
44
+
- The train information feed does not provide the details regarding the train's delays and other useful information that Infofer offers with their service. This will be updated in the future.
39
45
40
-
Public information web-service provided by CFR S.A. through Informatica Feroviara: http://appiris.infofer.ro/SosPlcRO.aspx, appiris.infofer.ro/MyTrainRO.aspx, http://appiris.infofer.ro/MersTrenRo.aspx. This is information from infrastructure administration and not a specific passenger carrier. Official passenger timetables are found here: http://mersultrenurilorcfr.ro, http://infofer.ro/ and static data source with timetables updated at the end of each year: http://data.gov.ro/organization/sc-informatica-feroviara-sa
46
+
Public information web-service provided by CFR S.A. through Informatica Feroviara: http://appiris.infofer.ro/SosPlcRO.aspx, appiris.infofer.ro/MyTrainRO.aspx, http://appiris.infofer.ro/MersTrenRo.aspx. This is information from infrastructure administration and not a specific passenger carrier. Official passenger timetables are found here: http://mersultrenurilorcfr.ro, http://infofer.ro/ and static data source with timetables updated at the end of each year: http://data.gov.ro/organization/sc-informatica-feroviara-sa
"description": "Live train information: srape-powered API with JSON endpoints for the Romanian national railway infrastructure company CFR S.A's realtime information web interface IRIS (built by state-railway IT company InfoFer).",
3
+
"version": "1.0.1",
4
+
"description": "Live train information: scrape-powered API with JSON endpoints for the Romanian national railway infrastructure company CFR S.A's realtime information web interface IRIS (built by state-railway IT company InfoFer).",
5
5
"main": "index.js",
6
6
"scripts": {
7
7
"test": "echo \"Error: no test specified\" && exit 1"
0 commit comments