db-vendo-client/docs/refresh-journey.md
Jannis R 339d64e901
convert to ESM 💥📝
2022-11-18 19:20:03 +01:00

1.5 KiB

refreshJourney(refreshToken, [opt])

refreshToken must be a string, taken from journey.refreshToken.

With opt, you can override the default options, which look like this:

{
	stopovers: false, // return stations on the way?
	polylines: false, // return a shape for each leg?
	tickets: false, // return tickets? only available with some profiles
	subStops: true, // parse & expose sub-stops of stations?
	entrances: true, // parse & expose entrances of stops/stations?
	remarks: true, // parse & expose hints & warnings?
	language: 'en' // language to get results in
}

Response

As an example, we're going to use the VBB profile:

import {createClient} from 'hafas-client'
import {vbbProfile} from 'hafas-client/p/vbb.js'

const client = createClient(vbbProfile)

// Hauptbahnhof to Heinrich-Heine-Str.
const {journeys} = await client.journeys('900000003201', '900000100008', {results: 1})

// later, fetch up-to-date info on the journey
const {
	journey,
	realtimeDataUpdatedAt,
} = await client.refreshJourney(journeys[0].refreshToken, {stopovers: true, remarks: true})

journey is a single Friendly Public Transport Format v2 draft journey, in the same format as returned by journeys().

realtimeDataUpdatedAt is a UNIX timestamp reflecting the latest moment when (at least some of) the response's realtime data have been updated.