Deutsche Bahn CLI
Search train connections using the bahn-cli tool.
Installation
The tool should be installed globally or in the workspace. If not installed:
CODEBLOCK0
Usage
Search train connections:
CODEBLOCK1
Options
- -
--date YYYY-MM-DD - Departure date (default: today) - INLINECODE2 - Departure time (default: current time)
- INLINECODE3 - Number of results to show (default: 5)
Examples
Search connections from Hannover to Bonn:
CODEBLOCK2
Search with specific date and time:
CODEBLOCK3
Station Names
- - Use common German station names
- "Hbf" means Hauptbahnhof (main station)
- Examples: "Berlin Hbf", "München Hbf", "Frankfurt(Main)Hbf", "Köln Hbf"
- Station names are case-insensitive
Output
The tool shows:
- - Departure and arrival times
- Platform numbers
- Duration
- Number of changes
- Intermediate stops for connections with changes
- Train numbers (ICE, IC, RE, etc.)
Notes
- - The CLI uses the db-vendo-client library
- Some station names in output may show "undefined" (cosmetic issue, doesn't affect functionality)
- Direct connections are listed first
- Times are in 24-hour format
Deutsche Bahn CLI
使用 bahn-cli 工具查询火车连接。
安装
该工具应全局安装或在工作区中安装。如果尚未安装:
bash
cd ~/Code/bahn-cli && npm install
使用方法
查询火车连接:
bash
cd ~/Code/bahn-cli && node index.js search <出发地> <目的地> [选项]
选项
- - --date YYYY-MM-DD - 出发日期(默认:今天)
- --time HH:MM - 出发时间(默认:当前时间)
- --results <数量> - 显示的结果数量(默认:5)
示例
查询从汉诺威到波恩的连接:
bash
cd ~/Code/bahn-cli && node index.js search Hannover Hbf Bonn Hbf --results 3
查询指定日期和时间的连接:
bash
cd ~/Code/bahn-cli && node index.js search Berlin München --date 2026-02-05 --time 14:30
车站名称
- - 使用常见的德国车站名称
- Hbf 表示 Hauptbahnhof(主火车站)
- 示例:Berlin Hbf、München Hbf、Frankfurt(Main)Hbf、Köln Hbf
- 车站名称不区分大小写
输出
该工具显示:
- - 出发和到达时间
- 站台号
- 行程时长
- 换乘次数
- 有换乘的连接的中途停靠站
- 列车编号(ICE、IC、RE 等)
备注
- - CLI 使用 db-vendo-client 库
- 输出中的某些车站名称可能显示为 undefined(外观问题,不影响功能)
- 直达连接优先列出
- 时间采用 24 小时制