to
must be an FPTF 1.2.0
stop
or station
. See journeys()
for details.
With opt
, you can override the default options, which look like this:
{
accessibility: 'none', // 'none', 'partial' or 'complete'
stopovers: false, // return stations on the way?
polylines: false, // return leg shapes?
transferTime: 0, // minimum time for a single transfer in minutes
tickets: false, // return tickets?
remarks: true // parse & expose hints & warnings?
}
Note: As stated in the Friendly Public Transport Format 1.2.0
, the returned departure
and arrival
times include the current delay. The departureDelay
/arrivalDelay
fields express how much they differ from the schedule.
As an example, we're going to use the DB profile:
const createClient = require('hafas-client')
const dbProfile = require('hafas-client/p/db')
const berlinSüdkreuz = '8011113'
const münchenHbf = '8000261'
const kölnHbf = '8000207'
const client = createClient(dbProfile, 'my-awesome-program')
// find any journey from Berlin Südkreuz to München Hbf
const [journey] = await client.journeys(berlinSüdkreuz, münchenHbf, {results: 1, stopovers: true})
// find the ICE leg
const leg = journey.legs.find(l => l.line.product === 'nationalExp')
// find the stopover at the stop you've just passed
const previousStopover = leg.stopovers.find(st => st.departure && new Date(st.departure) < Date.now())
// find journeys from the ICE train to Köln Hbf
const journeys = await client.journeysFromTrip(leg.id, previousStopover, kölnHbf)
journeys
will be an array of FPTF 1.2.0
journey
s, as documented in journeys()
.