db-vendo-client/docs
2021-10-18 17:18:39 +02:00
..
arrivals.md query arrivals , docs 📝 2018-06-26 18:13:41 +02:00
changelog.md changelog 📝; 5.20.0 2021-10-18 17:18:39 +02:00
departures.md parseArrOrDep: export currentTripLocation 📝 2021-10-12 17:53:28 +02:00
hafas-mgate-api.md improve docs 📝 2020-03-18 21:34:43 +01:00
journeys-from-trip.md link to FPTF v2 draft spec 📝 2021-08-18 16:00:16 +02:00
journeys.md parseJourneyLeg/parseTrip: expose currentLocation 📝 2021-10-12 17:37:34 +02:00
lines.md add lines() 2020-11-28 11:25:43 +01:00
locations.md add subStops & entrances options 2020-05-21 17:51:25 +02:00
migrating-to-5.md changelog 📝, 5.0.0 2020-01-05 18:31:06 +01:00
nearby.md link to FPTF v2 draft spec 📝 2021-08-18 16:00:16 +02:00
profile-boilerplate.js tweak "writing a profile" guide 📝 2019-02-28 16:45:31 +01:00
radar.md link to FPTF v2 draft spec 📝 2021-08-18 16:00:16 +02:00
reachable-from.md link to FPTF v2 draft spec 📝 2021-08-18 16:00:16 +02:00
readme.md journeysFromTrip: docs 📝 2021-08-04 15:21:00 +02:00
refresh-journey.md link to FPTF v2 draft spec 📝 2021-08-18 16:00:16 +02:00
remarks.md add remarks() 2020-11-28 11:25:43 +01:00
server-info.md add serverInfo(), E2E tests 2020-11-28 11:25:43 +01:00
stop.md parseLocation: parse entrances & sub-stops lists 2020-05-21 17:51:25 +02:00
trip.md parseJourneyLeg/parseTrip: expose currentLocation 📝 2021-10-12 17:37:34 +02:00
trips-by-name.md add tripsByName() method, docs 📝 2020-10-06 22:22:30 +02:00
writing-a-profile.md link to FPTF v2 draft spec 📝 2021-08-18 16:00:16 +02:00

API documentation

Migrating from an old hafas-client version

Throttling requests

There's opt-in support for throttling requests to the endpoint.

const createClient = require('hafas-client')
const withThrottling = require('hafas-client/throttle')
const dbProfile = require('hafas-client/p/db')

// create a throttled HAFAS client with Deutsche Bahn profile
const client = createClient(withThrottling(dbProfile), 'my-awesome-program')

// Berlin Jungfernheide to München Hbf
client.journeys('8011167', '8000261', {results: 1})
.then(console.log)
.catch(console.error)

You can pass custom values for the nr of requests (limit) per interval into withThrottling:

// 2 requests per second
const throttledDbProfile = withThrottling(dbProfile, 2, 1000)
const client = createClient(throttledDbProfile, 'my-awesome-program')

Retrying failed requests

There's opt-in support for retrying failed requests to the endpoint.

const createClient = require('hafas-client')
const withRetrying = require('hafas-client/retry')
const dbProfile = require('hafas-client/p/db')

// create a client with Deutsche Bahn profile that will retry on HAFAS errors
const client = createClient(withRetrying(dbProfile), 'my-awesome-program')

// Berlin Jungfernheide to München Hbf
client.journeys('8011167', '8000261', {results: 1})
.then(console.log)
.catch(console.error)

You can pass custom options into withRetrying. They will be passed into retry.

// retry 2 times, after 10 seconds & 30 seconds
const retryingDbProfile = withRetrying(dbProfile, {
	retries: 2,
	minTimeout: 10 * 1000,
	factor: 3
})
const client = createClient(retryingDbProfile, 'my-awesome-program')

Writing a profile

Check the guide.

General documentation for mgate.exe APIs

hafas-mgate-api.md