CLI tool for searching Deutsche Bahn train connections using the official DB API.
- Search train connections between any two stations
- Support for departure date and time
- Shows departure/arrival times, duration, and number of changes
- Displays intermediate stops for connections with changes
- Clean, formatted output
- Direct connections are clearly marked
git clone <repository-url>
cd bahn-cli
npm installnpm install -g bahn-cliOr from local development:
npm install -g .Search for connections from Berlin to Munich:
bahn search Berlin MünchenSearch for connections on January 25, 2026 at 14:30:
bahn search Berlin München --date 2026-01-25 --time 14:30bahn search Berlin München --date 2026-01-25 --time 18:00 --arrivalbahn search Berlin Hamburg --results 10| Option | Description |
|---|---|
<from> |
Origin station name |
<to> |
Destination station name |
--date YYYY-MM-DD |
Departure date (defaults to today) |
--time HH:MM |
Departure time (defaults to 12:00) |
--arrival |
Search for arrival-based connections |
--results <number> |
Number of results to show (default: 5) |
Searching connections from "Berlin" to "München"...
Departure: 2026-01-25 at 14:00
Connections:
═══════════════════════════════════════════════════════════════════════════════
🚆 Connection 1
14:15 Berlin Hbf → 17:32 München Hbf
Duration: 3h 17m | Direct
14:15 Berlin Hbf, Gl. 12 [ICE 1234]
🚆 Connection 2
14:30 Berlin Hbf → 18:15 München Hbf
Duration: 3h 45m | 1 change
Stops:
Dep: 14:30 Berlin Hbf, Gl. 8 [ICE 567]
Via: 16:15 Nürnberg Hbf, Gl. 5 [ICE 890]
Arr: 18:15 München Hbf, Gl. 12 [ICE 890]
═══════════════════════════════════════════════════════════════════════════════
Found 2 connections
- Station names are case-insensitive
- Use common station names (e.g., "Berlin Hbf", "München Hbf")
- The tool shows up to 5 connections by default
- Direct connections are always listed first
- Times are shown in 24-hour format
- Node.js 14.0 or higher
- npm 6.0 or higher
- Internet connection (for querying the DB API)
ISC License
Built using db-vendo-client - A JavaScript client for Deutsche Bahn public transport APIs.