Skip to content

CLI tool for Deutsche Bahn train connections using db-vendo-client

Notifications You must be signed in to change notification settings

tobiasbischoff/bahn-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bahn-cli

CLI tool for searching Deutsche Bahn train connections using the official DB API.

Features

  • 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

Installation

Local installation (development)

git clone <repository-url>
cd bahn-cli
npm install

Global installation

npm install -g bahn-cli

Or from local development:

npm install -g .

Usage

Basic search

Search for connections from Berlin to Munich:

bahn search Berlin München

Search with specific date and time

Search for connections on January 25, 2026 at 14:30:

bahn search Berlin München --date 2026-01-25 --time 14:30

Search for arrival-based connections

bahn search Berlin München --date 2026-01-25 --time 18:00 --arrival

Show more results

bahn search Berlin Hamburg --results 10

Command options

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)

Examples

Example output

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

Tips

  • 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

Requirements

  • Node.js 14.0 or higher
  • npm 6.0 or higher
  • Internet connection (for querying the DB API)

License

ISC License

Acknowledgments

Built using db-vendo-client - A JavaScript client for Deutsche Bahn public transport APIs.

About

CLI tool for Deutsche Bahn train connections using db-vendo-client

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published