API v 1.0
Welcome to the iRail API! Before you start implementing this API, a lot of code has been written already! Feel free to look around on our WrapperCode page for more information on wrappers for your programming language of choice.
1. List all stations
Request
arguments
?lang= FR EN NL or DE
We also support &format=kml for the stationslist
Response
<stations timestamp="050810">
<station locationX="4.038586" locationY="50.1345678" defaultname="Aalst">
Aalst
</station>
...
</stations>
2. Schedules
Request
http://api.irail.be/connections/?to=STATION1&from=STATION2 (OPTIONAL:) &date=311210&time=2359&timeSel=arrive or depart&typeOfTransport=train;bus;taxi
date
dmy (day of month with leading 0, number of the month with leading 0, 10 or 11 (for 2010 or 2011))
time
Hours in 24 hour format concatenated with minutes with leading 0!
timeSel
Whether the date & time are for arrival or depart. Should be "arrive" or "depart"
typeOfTransport
Semicolon separated list of supported transportations
Response
(with random data)
<connections>
<connection id="0">
<departure delay="xx"> <!--xx in seconds-->
<station locationX="4.038586" locationY="50.943053">
AALST
</station>
<time formatted="Y-m-d\TH:i:s\Z"> <!-- time in iso 8601 -->
U <!--(= unixtime)-->
</time>
<vehicle>
Be.NMBS.P2000
</vehicle>
<platform normal="yes">
3
</platform>
</departure>
<vias number="1">
<via id="0">
<arrival>
<time formatted="Y-m-d\TH:i:s\Z">
U <!--(= unixtime)-->
</time>
<platform>
5
</platform>
</arrival>
<depart>
<time formatted="iso8601">
U <!--(= unixtime)-->
</time>
<platform>
6
</platform>
</depart>
<timeBetween>xx</timeBetween>
<station locationX="..." locationY="...">
GENT SINT PIETERS
</station>
<vehicle>
Be.NMBS.P2000
</vehicle>
</via>
</vias>
<arrival delay="xx"> <!--delay on arrival in seconds -->
<station location="... ..." >
HARELBEKE
</station>
<time formatted="Y-m-d\TH:i\Z">
U <!--(= unixtime)-->
</time>
<vehicle>
Be.NMBS.P2000
</vehicle>
<platform normal="true" >
1
</platform>
</arrival>
<duration delay="yes">
seconds
</duration>
</connection>
...
</connections>
3. Liveboards
Request
liveboard/?station=STATIONNAME&fast=true or liveboard/?id=BE.NMBS.1
fast
Because of the recent changes in the internal system we were not able to link every station to a geolocation and internal id. Therefore we had to write a very slow workaround for this. If you don't need geocoordinates or the id, add: &fast=true to your URL.
station
Name of the station
id
id returned by a previous request
date
date of depart/arrival - mmddyy
time
time of depart/arrival -
arrdep
DEP or ARR for arrival or departure
Response
<liveboard version="1.0" timestamp="123456789">
<station locationX="4.21485" locationY="...">
GENT ST P [B]
</station>
<departures number="2">
<departure delay="xx" id="0">
<station locationX="..." locationY="...">
STATIONNAME
</station>
<vehicle>
Be.NMBS.P2000
</vehicle>
<time formatted="iso8601">U</time>
<platform>X</platform>
</departure>
<departure delay="xx" id="1">
<station locationX="..." locationY="...">
STATIONNAME
</station>
<vehicle>
Be.NMBS.P2001
</vehicle>
<time formatted="iso8601">U</time>
<platform>X</platform>
</departure>
</departures>
</liveboard>
4. Vehicle
Request
vehicle/?id=Be.NMBS.P1234&fast=true
fast
Because of the recent changes in the internal system we were not able to link every station to a geolocation and internal id. Therefore we had to write a very slow workaround for this. If you don't need geocoordinates or the id, add: &fast=true to your URL.
id
specify the vehicle id. This should be according the iRail specification
Response
<vehicleinformation version="1.0" timestamp="1289951643">
<vehicle locationX="0" locationY="0">
BE.NMBS.P8080
</vehicle>
<stops number="2">
<stop id="0" delay="0">
<station id="BE.NMBS.429" locationY="50.854421" locationX="2.736304">POPERINGE</station>
<time formatted="2010-11-17T15:12:00Z">1290006720</time>
</stop>
<stop id="1" delay="X">
<station id="BE.NMBS.272" locationY="50.8474" locationX="2.876589">IEPER</station>
<time formatted="2010-11-17T15:21:00Z">1290007260</time>
</stop>
...
</stops>
</vehicleinformation>
Error Response
When incorrect requests has been made or when an error occurs, we will provide an error message like this:
<error version="1.0" timestamp="1289951590" code="1">
You should ...
</error>
at this moment code = 1 is a user error. code = 2 is a server error.
Arguments on all functions
lang
if you add &lang=
NL, EN, DE or FR
to a function, the given station will be interpreted in that language, and the stationnames will be outputted in that language.
format
Currently we support 2 formats: xml and json
- &format=xml will output the above examples
- &format=json will output the xml-converted json
- &format=jsonp&callback=foo will package the json string into a callback function.
Links
- Read about jsonp.
- Read about ISO 8601 (the time format).
- Read about unixtime (the second supported timeformat).
- Use one of our wrappers for your preferred language (see WrapperCode).
- Raw API statistics.
