Transport for Switzerland
TransportationThe Swiss public transport API is a comprehensive and powerful tool that provides up-to-date information directly from Switzerland's public transport data. This API stands out in its capacity to offer broad-ranging data, from specific station timetables to nationwide connections, all of which are in a simple and user-friendly JSON format. Designed with developers in mind, it constituent an ideal platform not just for creating creative applications or websites focused on Swiss public transport but also for integrating Swiss transport data into existing projects or platforms.
This API also shines in its adherence to the principles of openness and accessibility. With its documentation hosted on https://transport.opendata.ch/, it crushes barriers and positions itself as an enticing proposition for developers around the globe. In effect, it is an intuitive and straightforward interface that, while Swiss-focused, has benefits that go beyond the borders of Switzerland.
The benefits of using the Swiss public transport API include:
- Providing real-time, accurate information on Swiss public transport
- Offering broad-ranging data, including specific station timetables and nationwide connections
- Encouraging innovation with its user-friendly JSON format
- Empowering developers with its open and accessible design
- Enriching existing platforms with integrated Swiss transport data
Here is a JavaScript code example for calling the API:
const axios = require('axios');
axios.get('https://transport.opendata.ch/v1/stationboard', {
params: {
station: 'Zurich',
limit: 5
}
})
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error(`Error: ${error}`);
});
This code makes a GET request to the Swiss public transport API, retrieving the next 5 departures from Zurich station. All results are logged into the console, while any possible error triggers a console error message delivery.