The public transport organization SBB recently opened platform for customer information data on public transport in Switzerland. Anyone can obtain obtain data on public transport free of charge and get access to specific public transport services for all licensed transport companies in Switzerland. The platform provides timetable, real-time and actual data.
Checkout opentransportdata.swiss where you also can find a Cookbook, but which is currently available only in German. They implemented API VDV 431 is not a REST-API but rather uses simple POST request to get information. The current API allows
First you have to register yourself so you get access to the Developer Portal so you can generate the necessary API Key
First steps
Let’s try to do a TripRequest following the cookbook and let’s see what we get when we query for a trip between Bern and Luzern the 24.th of Dec. 2016 at 0900 departure time. Frist we need to get the correct DiDok ID for the station - I had a look in the published Excel. There are some things you need to consider
The current implementation of SBB only supports direct connections
You need to aggregate 850 in front of the Dst.Nr. found in the Excel sheet to get the correct DiDok ID
Select the correct Stations
I was looking for a connection between Bern Hauptbahnof (ID 7786) and Luzern Bahnhof (ID 8450)
{{ }}
Unfortunately this query returned and empty results which according to the Cookbook means no result found. Therefore I check the table again and find this:
{{ }}
So I actually have to take code 7000 (Bern) and 5000 (Luzern) for the query, which I place in a xml file for later usage:
Which returns a result, displaying several trips (click on “Code” to see the full response):
{{ }}
So let’s examine the first trip and see what information we have:
Duration: 60StartTime: 2016-12-24T07:00:00ZEndTime: 2016-12-24T08:00:00ZInterchanges = 0Arrival at "Neubaustrecke": 1970-01-01T00:00:00ZDeparture at "Neubaustrecke": 1970-01-01T00:00:00ZArrival in Zofingen: 2016-12-24T07:27:00ZDeparture in Zofingen: 2016-12-24T07:28:00ZArrival in Sursee: 2016-12-24T07:40:00ZDeparture in Sursee: 2016-12-24T07:41:00ZArrival in Luzern: 2016-12-24T08:00:00Z
When looking at the dates, I assume the entry with “Neubaustrecke” we can ignore, as they are not really a stop but rather just information where the train passes trough. The times are returned in Zulu time, which is expected. But what I was actually expecting is the trips concerning the “Departure time” around 0900 as entered in the tag DepArrTime. Unfortunately this is not clearly specified and the documentation only mentions that tag DepArrTime refers to “Departure or Arrival time” but I can nowhere specify whether the time in tag DepArrTime is actually the “Arrival” or the “Departure” time. However, when I cross-check the information with the official timetable, I actually can see the same information.
Conclusion
The provided data is impressive, as you do not only have timetable information but also information regarding stations (train stations, bus stops … and its location). The provided API - even so the API is limited and does not implement all features of the related standard - offers interested Developers to use the service to provide their own application while accessing accurate data. Really hats off for so much openess!
What is VDV-431
opentransportdata.swiss is referring to VDV-432 so I was wondering what this is. The VDV is an abbreviation for “Verband Deutscher Verkehrsunternehmen” (Association of German Transport Companies) and has a long history which goes back to 1846 as you can read on their page. The association organises the more than 600 public transport companies in Germany.
It advises and supports its member companies and politicians, supports the exchange of experience and know-how between the members and prepares technical, operational, legal and economic principles
One of these technical principles is the project "IP-KOM-ÖV”. This project defines concepts and architectures to provide IP-based communication platform for public transports using standardized ways. These concepts and architectures have been written down in the VDV documents which VDV-431 is one of them and is a a standard for real-time communication and information platform (Echtzeit Kommunikations- und Auskunftsplattform EKAP)¨.