Public transport routing across Europe. Merges data from API endpoints for various regions, in order to get better data than what one endpoint provides.
Why linked open transit data? explains the problem:
When travelling through larger regions or several countries by public transportation, finding out how and when to get to the destination is hard:
- People often need to use multiple, regionally limited apps to find out which trains/busses/ferries/etc. are available, because these apps often have imprecise (e.g. regarding accessibility), outdated (e.g. construction work) or just no data whatsoever about other regions. Doing this research across operator boundaries involves a lot of manual work. Essentially the user needs to do the job that computers should do: routing through sub-networks.
- When dealing with large distances (e.g. from Norway to France), this routing work becomes almost impossible for humans to do ad-hoc, because there are so many possible connections. Combined with e.g. cancellations & delays, users may never find the optimal connection because of that.
- Local, narrow-focused apps are not (as) accessible. They're often developed with a smaller budget, in some languages, without screen reader & offline support, have a bad UX, are only available for some platforms, etc.
- Apps built for current mainstream use cases are not future-proof. With the ongoing digitisation, diversification and increased on-demand features, they won't be able to deliver on people's mobility needs. (They barely do that right now.)
For a routing request from A (starting point) to B (destination), it will
For a departures/arrivals request for a station A, it will
Note: Right now, this only works with hafas-client@5
-compatible API clients.
Compared with the goals specified in Why linked open transit data?, this project can be seen as a "stepping stone" towards them:
Nevertheless, it
npm install derhuerst/pan-european-public-transport
pan-european-public-transport
expects a Redis server running on localhost:6379
. You can configure a different hostname/port via the REDIS_URL
environment variable.
The API mimicks the hafas-client@5
API.
const client = require('pan-european-public-transport')
const inBerlin = {
type: 'location',
address: 'Großer Bunkerberg in Volkspark Friedrichshain',
latitude: 52.526367, longitude: 13.432154
}
const inHamburg = {
type: 'location',
address: 'Hansestadt Hamburg - Neustadt, Johannisbollwerk 6',
latitude: 53.545056, longitude: 9.974467
}
const toHamburg = await client.journeys(inBerlin, inHamburg, {results: 1})
const [enrichedJourney] = toHamburg.journeys
console.log('enrichedJourney', enrichedJourney)
This will use the Deutsche Bahn endpoint for routing and enrich the journey using the VBB and HVV endpoints.
const wroclawGlowny = '5100069'
const [enrichedDeparture] = await client.departures('db', wroclawGlowny, {results: 1})
console.log('enrichedDeparture', enrichedDeparture)
This will fetch departures at Wrocław Główny using the Deutsche Bahn endpoint and enrich each departure using the PKP endpoint.
If you want to find out what it does, run with the following env var:
export DEBUG='pan-european-public-transport*,-pan-european-public-transport:hafas*,find-hafas-data-in-another-hafas*'
find-hafas-data-in-another-hafas
– Find data from one HAFAS endpoint in another one.stable-public-transport-ids
– Get stable IDs for public transport stations, etc.vbb-hafas
– JavaScript client for the VBB HAFAS API.db-hafas
– JavaScript client for the DB HAFAS API.insa-hafas
– JavaScript client for the NASA/INSA HAFAS API.If you have a question or need support using pan-european-public-transport
, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to the issues page.