mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-22 22:59:35 +02:00
docs
This commit is contained in:
parent
760a1bdb54
commit
e18ac3f8d3
3 changed files with 8 additions and 117 deletions
|
@ -1,96 +0,0 @@
|
|||
# DB profile for `hafas-client`
|
||||
|
||||
[*Deutsche Bahn (DB)*](https://en.wikipedia.org/wiki/Deutsche_Bahn) is the largest German long-distance public transport company. This profile adds *DB*-specific customizations to `hafas-client`. Consider using [`db-hafas`](https://github.com/derhuerst/db-hafas#db-hafas), to always get the customized client right away.
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import {createClient} from 'hafas-client'
|
||||
import {profile as dbProfile} from 'hafas-client/p/db/index.js'
|
||||
|
||||
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
|
||||
|
||||
// create a client with DB profile
|
||||
const client = createClient(dbProfile, userAgent)
|
||||
```
|
||||
|
||||
|
||||
## Customisations
|
||||
|
||||
- supports 1st and 2nd class with `journey()`
|
||||
- supports [their loyalty cards](https://en.wikipedia.org/wiki/Deutsche_Bahn#Tickets) with `journey()`
|
||||
- parses *DB*-specific products (such as *InterCity-Express*)
|
||||
- exposes the cheapest ticket price for a `journey`
|
||||
- parses [*DB*-specific station info](#additional-station-info)
|
||||
|
||||
### additional station info
|
||||
|
||||
With the `db` profile, `hafas-client` will return more station information whenever the endpoint provides it:
|
||||
|
||||
```js
|
||||
{
|
||||
type: 'station',
|
||||
id: '8004585',
|
||||
name: 'Oberstdorf',
|
||||
// …
|
||||
facilities: {
|
||||
'3SZentrale': '089/13081055',
|
||||
parkingLots: true,
|
||||
bicycleParkingRacks: true,
|
||||
localPublicTransport: true,
|
||||
toilets: true,
|
||||
lockers: true,
|
||||
travelShop: true,
|
||||
stepFreeAccess: true,
|
||||
boardingAid: 'ja, um voranmeldung unter 01806 512 512* wird gebeten',
|
||||
taxis: true
|
||||
},
|
||||
reisezentrumOpeningHours: {
|
||||
Mo: '08:00-18:00',
|
||||
Di: '08:00-18:00',
|
||||
Mi: '08:00-18:00',
|
||||
Do: '08:00-18:00',
|
||||
Fr: '08:00-18:00',
|
||||
Sa: '09:00-14:00',
|
||||
So: '09:00-14:00'
|
||||
},
|
||||
// …
|
||||
stops: [{
|
||||
type: 'stop',
|
||||
id: '965503',
|
||||
name: 'Busbahnhof, Oberstdorf',
|
||||
// …
|
||||
reisezentrumOpeningHours: {
|
||||
Mo: '08:00-18:00',
|
||||
Di: '08:00-18:00',
|
||||
Mi: '08:00-18:00',
|
||||
Do: '08:00-18:00',
|
||||
Fr: '08:00-18:00',
|
||||
Sa: '09:00-14:00',
|
||||
So: '09:00-14:00'
|
||||
}
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
## Using the `loyaltyCard` option
|
||||
|
||||
```js
|
||||
import {data as loyaltyCards} from 'hafas-client/p/db/loyalty-cards.js'
|
||||
|
||||
hafas.journeys(from, to, {
|
||||
loyaltyCard: {type: data.BAHNCARD, discount: 25}
|
||||
})
|
||||
```
|
||||
|
||||
## Using the `routingMode` option
|
||||
|
||||
The default option is `REALTIME`. An explaination about different routing options can be found in [https://pastebin.com/qZ9WS3Cx](https://pastebin.com/qZ9WS3Cx). The option `HYBRID` is the default option (as of 18.07.2023) in the iOS DB mobile application and also shows cancelled trains (in contrast to the default option `REALTIME`).
|
||||
|
||||
```js
|
||||
import {routingModes} from 'hafas-client/p/db/routing-modes.js'
|
||||
|
||||
await hafas.journeys(from, to, {
|
||||
routingMode: routingModes.HYBRID,
|
||||
})
|
||||
```
|
|
@ -1,13 +0,0 @@
|
|||
// see https://pastebin.com/qZ9WS3Cx
|
||||
const routingModes = {
|
||||
OFF: 'OFF',
|
||||
INFOS: 'INFOS',
|
||||
FULL: 'FULL',
|
||||
REALTIME: 'REALTIME',
|
||||
SERVER_DEFAULT: 'SERVER_DEFAULT',
|
||||
HYBRID: 'HYBRID',
|
||||
};
|
||||
|
||||
export {
|
||||
routingModes,
|
||||
};
|
16
readme.md
16
readme.md
|
@ -7,16 +7,16 @@
|
|||
|
||||
This is a very early version. What works:
|
||||
|
||||
* rudimentary `/journeys` including lowest prices
|
||||
* `/locations`, `/locations/nearby`
|
||||
* `/departures`, `/arrivals`
|
||||
* `journeys()`, `refreshJourney()` including prices
|
||||
* `locations()`, `nearby()`
|
||||
* `departures()`, `arrivals()` boards
|
||||
|
||||
What doesn't work (yet, see TODO's scattered around the code):
|
||||
|
||||
* `/journeys` details like scheduledDays, stop/station groups, tickets, some line details ...
|
||||
* `/journeys` uses different tripIds compared to departure and arrival boards...
|
||||
* certain stop details like products for `/locations` and geopositions for departures and arrivals
|
||||
* some query options like BahnCards etc., certain filters for boards
|
||||
* `journeys()` details like scheduledDays, stop/station groups, some line details ...
|
||||
* `journeys()` uses different tripIds compared to departure and arrival boards...
|
||||
* certain stop details like products for `locations()` and geopositions for boards
|
||||
* some query options/filters (e.g. direction for boards)
|
||||
* all other endpoints
|
||||
|
||||
Feel free report anything that you stumble upon via Issues or create a PR :)
|
||||
|
@ -34,7 +34,7 @@ Strictly speaking, permission is necessary to use this library with the DB APIs.
|
|||
|
||||
## Usage
|
||||
|
||||
See an example in [api.js](api.js). It shows how you can use `db-vendo-client` together with `hafas-rest-api` in order to run a [FPTF](https://github.com/public-transport/friendly-public-transport-format) API server.
|
||||
See an example in [api.js](api.js). It shows how you can use `db-vendo-client` together with `hafas-rest-api` in order to run a [FPTF](https://github.com/public-transport/friendly-public-transport-format) API server. The [Dockerfile](Dockerfile) serves this API.
|
||||
|
||||
There are [community-maintained TypeScript typings available as `@types/hafas-client`](https://www.npmjs.com/package/@types/hafas-client).
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue