db-vendo-client/readme.md

82 lines
5.1 KiB
Markdown
Raw Normal View History

2024-12-07 16:16:31 +00:00
# db-vendo-client
2016-06-22 01:39:04 +02:00
2025-01-03 11:39:55 +00:00
**A client for the new "vendo"/"movas" bahn.de APIs, a drop-in replacement for [hafas-client](https://github.com/public-transport/hafas-client/).**
2024-12-07 23:56:34 +00:00
![ISC-licensed](https://img.shields.io/github/license/public-transport/db-vendo-client.svg)
2020-04-18 17:15:46 +02:00
[![support Jannis via GitHub Sponsors](https://img.shields.io/badge/support%20Jannis-donate-fa7664.svg)](https://github.com/sponsors/derhuerst)
2016-06-22 01:39:04 +02:00
2024-12-07 16:16:31 +00:00
This is a very early version. What works:
2025-01-03 11:39:55 +00:00
* `journeys()`, `refreshJourney()` including tickets
2024-12-11 23:57:49 +00:00
* `locations()`, `nearby()`
* `departures()`, `arrivals()` boards
2024-12-18 02:02:05 +00:00
* `trip()`
2016-06-22 01:39:04 +02:00
2024-12-07 23:48:17 +00:00
What doesn't work (yet, see TODO's scattered around the code):
2024-12-11 23:57:49 +00:00
* `journeys()` details like scheduledDays, stop/station groups, some line details ...
2025-01-03 11:39:55 +00:00
* loadFactor and other details in boards
2025-01-08 23:02:57 +00:00
* certain stop details like products for `locations()` and geopositions and remarks for boards this can be remedied by turning on `enrichStations` in the config, enriching location info with [db-hafas-stations](https://github.com/derhuerst/db-hafas-stations).
2025-01-03 11:39:55 +00:00
* some query options/filters (e.g. routingMode for journeys, direction for boards)
2025-01-08 23:02:57 +00:00
* all other endpoints (`tripsByName()`, `radar()`, `journeysFromTrip()`, `reachableFrom()`, `remarks()`, `lines()`, `station()`)
2017-11-13 00:38:09 +01:00
2025-01-03 11:39:55 +00:00
Depending on the configured profile, db-vendo-client will use multiple different DB APIs that offer varying functionality, so choose wisely:
| | `db` Profile | `dbnav` Profile |
| ------------- | ------------- | ------------- |
| no API key required | ✅ | ✅ |
| max duration boards | 12h | 1h |
2025-01-08 23:02:57 +00:00
| remarks | not for boards | ✅ (still no `remarks()` endpoint) |
2025-01-03 11:39:55 +00:00
| cancelled trips | not contained in boards | contained with cancelled flag |
| tickets | only for `refreshJourney()` | only for `refreshJourney()`, mutually exclusive with polylines |
| polylines | only for `trip()` | only for `refreshJourney()/trip()`, mutually exclusive with tickets |
2025-01-09 00:07:17 +00:00
| trip ids used | HAFAS trip ids for journeys, RIS trip ids for boards (static on train splits?) | HAFAS trip ids |
| line.id/fahrtNr used | unreliable/route id for journeys, actual fahrtNr for boards | unreliable/route id |
| adminCode/operator | adminCode only for boards | only for `journeys()` |
2025-01-08 23:02:57 +00:00
| `stop()` | ❌ | ✅ |
2025-01-03 11:39:55 +00:00
| assumed backend API stability | less stable | more stable |
2024-12-16 20:22:36 +00:00
Feel free to report anything that you stumble upon via Issues or create a PR :)
2024-12-07 23:48:17 +00:00
2024-12-07 23:56:34 +00:00
Also consult the relevant **[documentation](https://github.com/public-transport/hafas-client/blob/main/docs/readme.md)** of [hafas-client](https://github.com/public-transport/hafas-client/) (but beware of the limited functionality of db-vendo-client).
2017-11-13 00:38:09 +01:00
2016-06-22 01:39:04 +02:00
2024-12-07 16:16:31 +00:00
## Background
2025-01-03 11:39:55 +00:00
After DB has switched to the new "vendo"/"movas" platform for bahn.de and DB Navigator, the old [HAFAS](https://de.wikipedia.org/wiki/HAFAS) API (see [hafas-client](https://github.com/public-transport/hafas-client/)) seems to become less and less reliable (server unreachable, missing prices, etc.) This project aims to enable easy switching to the new APIs. However, not all information will be available from the new APIs.
2025-01-03 11:39:55 +00:00
Actually, db-vendo-client is a wrapper around multiple different APIs, currently the bahn.de API for route planning and the regio-guide RIS API for boards for the `db` profile and the DB Navigator API for the `dbnav` profile. See some [notes about the various new APIs at DB](docs/db-apis.md).
2024-12-10 17:57:56 +00:00
Strictly speaking, permission is necessary to use this library with the DB APIs.
2016-06-22 01:39:04 +02:00
## Usage
2025-01-08 18:35:13 +00:00
Use it as a dependency, e.g. just replacing [hafas-client](https://github.com/public-transport/hafas-client/):
```
npm i db-vendo-client
```
2025-01-09 00:11:30 +00:00
See an example in [api.js](api.js). It shows how you can use `db-vendo-client` together with [hafas-rest-api](https://github.com/public-transport/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 (using the `db` profile):
2025-01-08 18:35:13 +00:00
```
docker run -e USER_AGENT=my-awesome-program -p 3000:3000 ghcr.io/public-transport/db-vendo-client
```
2017-11-13 00:38:09 +01:00
2024-12-07 16:16:31 +00:00
There are [community-maintained TypeScript typings available as `@types/hafas-client`](https://www.npmjs.com/package/@types/hafas-client).
## Related Projects
2024-12-07 16:16:31 +00:00
- [hafas-client](https://github.com/public-transport/hafas-client/) including further related projects
2024-12-07 23:56:34 +00:00
- [hafas-rest-api](https://github.com/public-transport/hafas-rest-api/) expose a hafas-client or db-vendo-client instance as a REST API
2024-12-07 16:16:31 +00:00
- [db-rest](https://github.com/derhuerst/db-rest/) for the legacy DB HAFAS endpoint
- [`*.transport.rest`](https://transport.rest/)  Public APIs wrapping some HAFAS endpoints.
2016-06-22 01:39:04 +02:00
## Contributing
2024-12-07 23:56:34 +00:00
If you **have a question**, **found a bug** or want to **propose a feature**, please [open an Issue](https://github.com/public-transport/db-vendo-client/issues).
2020-03-18 21:32:05 +01:00
2024-12-07 23:56:34 +00:00
This project needs help! Check the [list of "help wanted" Issues](https://github.com/public-transport/db-vendo-client/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22).
If you're contributing code, please read the [contribution guidelines](contributing.md).