db-vendo-client/docs
Jannis R f771e9fb5d
changelog 📝, 5.0.3
[ci skip]
2020-01-29 02:53:02 +01:00
..
arrivals.md query arrivals , docs 📝 2018-06-26 18:13:41 +02:00
changelog.md changelog 📝, 5.0.3 2020-01-29 02:53:02 +01:00
departures.md adapt docs to c2dc874 📝 2020-01-05 17:55:49 +01:00
hafas-mgate-api.md move authentication docs to mgate.exe page 📝 2019-12-25 20:00:38 +01:00
journeys.md improve docs readability 📝 2020-01-05 17:55:56 +01:00
locations.md adapt docs & tests to eb3ffba 📝 2019-02-28 16:45:31 +01:00
migrating-to-4.md changelog & "migration to 4" guide 📝, 4.0.0 2019-02-28 17:02:18 +01:00
migrating-to-5.md changelog 📝, 5.0.0 2020-01-05 18:31:06 +01:00
nearby.md departures/arrivals, locations, nearby, stop: opt.stationLines -> linesOfStops 💥 📝 2019-02-28 16:45:18 +01:00
profile-boilerplate.js tweak "writing a profile" guide 📝 2019-02-28 16:45:31 +01:00
radar.md improve docs readability 📝 2020-01-05 17:55:56 +01:00
reachable-from.md readableFrom: make maxDuration optional 2018-11-01 19:39:04 +01:00
readme.md request() via profile 💥 2020-01-05 18:10:09 +01:00
refresh-journey.md link to FPTF 1.2.0 📝 2018-09-22 19:25:01 +02:00
stop.md departures/arrivals, locations, nearby, stop: opt.stationLines -> linesOfStops 💥 📝 2019-02-28 16:45:18 +01:00
trip.md improve docs readability 📝 2020-01-05 17:55:56 +01:00
writing-a-profile.md minor fix, changelog 📝, 5.0.2 2020-01-15 18:17:49 +01: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