iRail API / scraper
Latest commit 6612248 Aug 16, 2016 @pietercolpaert pietercolpaert committed on GitHub Merge pull request #256 from iRail/development
Failed to load latest commit information.
src Applied fixes from StyleCI Jun 26, 2016
storage Fixed #56, #55, #54 Dec 17, 2015
.env.example Additional merge changes Jul 24, 2016
.gitignore Make sure that the composer.json is ignore, otherwise developers that… Jul 27, 2016 Clean up unused files, enhanced and removed unmaintained NS… Aug 30, 2015
composer.json Deleted the MongoDB dependencies and updated the Jul 26, 2016
phpunit.xml added dotenv Jul 9, 2015
robots.txt pulled in Quentins commit Aug 28, 2011


License AGPL-3.0 Join the chat at

iRail supports digital creativity concerning mobility in Belgium. This is an attempt to make the railway time schedules in Belgium easily available for anyone.

Our main site consists of a very easy mobile website to look up time schedules using our own API.

Native applications using the iRail API and created or supported by the iRail team are named BeTrains and RailerApp.

All information can be found on our blog at

Installation for development purposes

note: you'll also need to have nodejs, composer and PHP curl extension installed on your system

  • Step 1: Clone this repo
  • Step 2: composer install
  • Step 3: Make sure storage is writable: chmod 777 storage
  • Step 4: Run your test server: php -S localhost:8008 -t api
  • Step 5: Enjoy your own iRail API at http://localhost:8008/connections.php?from=Gent%20Sint%20Pieters&to=Antwerp

Optional, if you want to set up the iRail API with occupancy scores you will need to set up a MongoDB database:

  • Step 6: Install MongoDB
  • Step 7: Install the MongoDB module for PHP: pecl install mongodb
  • Step 8: Include MongoDB: composer require mongodb/mongodb:^1.0 (make sure to not commit the composer.json file)
  • Step 9: Add MongoDB environment variables: cp .env.example .env (If your MongoDB URL is different or you want another database name you can change this file)
  • Step 10: Import the data (the structural.csv file) in MongoDB: mongoimport -d irail -c structural --type csv --file occupancy/data/structural.csv --headerline
  • Step 11: Run the startscript to push structural data to the occupancy table: php occupancy/scripts/startscript.php
  • Step 12: Once the startscript has ran, the task of pushing strutural data to the occupancy table should be automated: crontab -e => 30 3 * * * php $PATH_TO_IRAIL_FOLDER/occupancy/scripts/cronjob.php
  • Step 13: Enjoy the occupancy scores in all the GET requests and the POST request: curl -H "Content-Type: application/json" -X POST -d '{"connection": "","from": "","date": "20160722","vehicle": "","occupancy":"","to":""}' http://localhost:8008/feedback/occupancy.php

Update stations list

Stations are updated through the irail/stations composer package. Just perform a composer update in the root of the project.

More links