Compare commits

..

No commits in common. "main" and "v6.9.0" have entirely different histories.
main ... v6.9.0

8 changed files with 31 additions and 25 deletions

View file

@ -634,9 +634,7 @@
"dbbahnhof",
"Deutschlandticket",
"fahrverguenstigungen",
"cancelation",
"MOTIS",
"motis"
"cancelation"
],
"ignorePaths": [
"docs/dumps/**",

View file

@ -1,4 +1,5 @@
import dbnavBase from '../dbnav/base.json' with { type: 'json' };
import dbregioguideBase from '../dbregioguide/base.json' with { type: 'json' };
import {products} from '../../lib/products.js';
// journeys()
@ -25,11 +26,12 @@ const {nearbyEndpoint} = dbnavBase;
// trip()
import {formatTripReq} from './trip-req.js';
const {tripEndpoint} = dbnavBase;
const tripEndpoint_dbnav = dbnavBase.tripEndpoint;
const tripEndpoint_dbregioguide = dbregioguideBase.tripEndpoint;
// arrivals(), departures()
import {formatStationBoardReq} from '../dbnav/station-board-req.js';
const {boardEndpoint} = dbnavBase;
import {formatStationBoardReq} from '../dbregioguide/station-board-req.js';
const {boardEndpoint} = dbregioguideBase;
const profile = {
locale: 'de-DE',
@ -53,7 +55,7 @@ const profile = {
nearbyEndpoint,
formatTripReq,
tripEndpoint,
tripEndpoint_dbnav, tripEndpoint_dbregioguide,
formatStationBoardReq,
boardEndpoint,

View file

@ -1,9 +1,16 @@
import {formatTripReq as hafasFormatTripReq} from '../dbnav/trip-req.js';
import {formatTripReq as risTripReq} from '../dbregioguide/trip-req.js';
const formatTripReq = ({profile, opt}, id) => {
const _profile = {...profile};
_profile['tripEndpoint'] = profile.tripEndpoint;
return hafasFormatTripReq({profile: _profile, opt}, id);
if (id.includes('#')) {
_profile['tripEndpoint'] = profile.tripEndpoint_dbnav;
return hafasFormatTripReq({profile: _profile, opt}, id);
}
_profile['tripEndpoint'] = profile.tripEndpoint_dbregioguide;
return risTripReq({profile: _profile, opt}, id);
};
export {

View file

@ -15,7 +15,7 @@ const profile = {
journeysOutFrwd: false,
departuresGetPasslist: false,
departuresStbFltrEquiv: true,
trip: true,
trip: false,
radar: false,
refreshJourney: false,
journeysFromTrip: false,

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "db-vendo-client",
"version": "6.10.0",
"version": "6.9.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "db-vendo-client",
"version": "6.10.0",
"version": "6.9.0",
"license": "ISC",
"dependencies": {
"content-type": "^1.0.5",

View file

@ -1,7 +1,7 @@
{
"name": "db-vendo-client",
"description": "Client for bahn.de public transport APIs.",
"version": "6.10.0",
"version": "6.9.0",
"type": "module",
"main": "index.js",
"files": [

View file

@ -27,21 +27,21 @@ Depending on the configured profile, db-vendo-client will use multiple different
| ------------- | ------------- | ------------- | ------------- | ------------- | ------------- |
| no API key required | ✅ | ✅ | ✅ | ✅ | ❌ |
| all above endpoints supported | ✅ | ✅ | except `stop()` | only boards | only boards |
| duration for boards | always 1h | always 1h | always 1h | up to 6h, only from current time | up to 12h |
| remarks | for boards only most important remarks | for boards only most important remarks | all remarks on boards and journeys | most remarks | all remarks |
| cancelled trips | contained with cancelled flag | contained with cancelled flag | contained with cancelled flag | contained with cancelled flag | contained with cancelled flag |
| duration for boards | up to 12h | always 1h | always 1h | up to 6h, only from current time | up to 12h |
| remarks | not for boards | for boards only most important remarks | all remarks on boards and journeys | most remarks | all remarks |
| cancelled trips | contained with cancelled flag in journeys, not contained in boards | contained with cancelled flag | contained with cancelled flag | contained with cancelled flag | contained with cancelled flag |
| tickets | only for `refreshJourney()`, mutually exclusive with polylines | only for `refreshJourney()`, mutually exclusive with polylines | only for `refreshJourney()`, mutually exclusive with polylines | ❌ | ❌ |
| polylines | only for `refreshJourney()/trip()`, mutually exclusive with tickets | only for `refreshJourney()/trip()`, mutually exclusive with tickets | only for `refreshJourney()/trip()`, mutually exclusive with tickets | ❌ | ❌ |
| trip ids used | HAFAS trip ids | HAFAS trip ids | HAFAS trip ids | RIS trip ids | RIS trip ids |
| line.id/fahrtNr used | actual fahrtNr for journeys, unreliable/route id for boards and `trip()` | actual fahrtNr for journeys, unreliable/route id for boards and `trip()` | unreliable/route id | unreliable/route id | ✅ |
| adminCode/operator | only for journeys | only for journeys | only operator | only adminCode | ✅ |
| polylines | only for `refreshJourney()` (mutually exclusive with tickets) and for `trip()` (only for HAFAS trip ids) | only for `refreshJourney()/trip()`, mutually exclusive with tickets | only for `refreshJourney()/trip()`, mutually exclusive with tickets | ❌ | ❌ |
| trip ids used | HAFAS trip ids for journeys, RIS trip ids for boards (static on train splits?) | HAFAS trip ids | HAFAS trip ids | RIS trip ids | RIS trip ids |
| line.id/fahrtNr used | actual fahrtNr | actual fahrtNr for journeys, unreliable/route id for boards and `trip()` | unreliable/route id | unreliable/route id | ✅ |
| adminCode/operator | | only for journeys | only operator | only adminCode | ✅ |
| stopovers | not in boards | not in boards | ✅ | some | ✅ |
| assumed backend API stability | less stable | more stable | less stable | less stable | more stable |
| quotas | 60 requests per minute (IPv4) | 60 requests per minute (IPv4) | aggressive blocking (IPv4/IPv6) | ? | depends on API key |
| quotas | 60 requests per minute for journeys, unknown for boards (IPv4) | 60 requests per minute (IPv4) | aggressive blocking (IPv4/IPv6) | ? | depends on API key |
> [!IMPORTANT]
> If you think that for your project, quotas may become an issue, [consider alternative ways to obtain the data you need.](https://github.com/derhuerst/db-rest/blob/6/docs/readme.md#why-not-to-use-this-api), e.g. [motis-fptf-client](https://github.com/motis-project/motis-fptf-client) (a drop-in replacement for db-vendo-client/hafas-client) in conjunction with https://transitous.org or a self-hosted [MOTIS](https://github.com/motis-project/motis) instance.
> If you think that for your project, quotas may become an issue, [consider alternative ways to obtain the data you need.](https://github.com/derhuerst/db-rest/blob/6/docs/readme.md#why-not-to-use-this-api).
Feel free to report anything that you stumble upon via Issues or create a PR :)
@ -92,7 +92,6 @@ There are [community-maintained TypeScript typings available as `@types/hafas-cl
- [hafas-client](https://github.com/public-transport/hafas-client/) including further related projects
- [hafas-rest-api](https://github.com/public-transport/hafas-rest-api/) expose a hafas-client or db-vendo-client instance as a REST API
- [db-rest](https://github.com/derhuerst/db-rest/) for the legacy DB HAFAS endpoint
- [motis-fptf-client](https://github.com/motis-project/motis-fptf-client) a drop-in replacement for db-vendo-client/hafas-client wrapping a [MOTIS](https://github.com/motis-project/motis) instance
- [`*.transport.rest`](https://transport.rest/)  Public APIs wrapping some HAFAS endpoints.
## Contributing

View file

@ -38,10 +38,10 @@ tap.test('db trip(): dynamic request formatting', (t) => {
const reqDbNav = profile.formatTripReq(ctx, tripIdHafas);
delete reqDbNav.headers['X-Correlation-ID'];
// const reqDbRegioGuide = profile.formatTripReq(ctx, tripIdRis);
const reqDbRegioGuide = profile.formatTripReq(ctx, tripIdRis);
t.same(reqDbNav, reqDbNavExpected);
// t.same(reqDbRegioGuide, reqDbRegioGuideExpected);
t.same(reqDbRegioGuide, reqDbRegioGuideExpected);
t.end();
});