bahn

star 1

A comprehensive suite of commands for tracking Deutsche Bahn trains

rutkk By rutkk schedule Updated 3/6/2026

name: bahn description: A comprehensive suite of commands for tracking Deutsche Bahn trains version: 1.0.0 metadata: openclaw: requires: bins: - node install: - kind: node package: db-vendo-client - kind: node package: devalue - kind: node package: fast-xml-parser emoji: "๐Ÿš†" homepage: https://github.com/ableitung/openclaw-bahn os: - macos - linux


Bahn

A comprehensive suite of commands for Deutsche Bahn trains - live departures, delay tracking, Baustellen/disruption alerts, journey planning, connection parsing, historical delay stats, and delay predictions. No API keys needed.

Flags

Flag What it does When to use
--predict Runs the exponential delay model (transferProb, zugbindungProb) User asks about probability of catching a transfer or Zugbindung being lifted
--stats Fetches historical bahn.expert aggregate data per train User asks about historical delay patterns for a specific train

Examples

# Search for a train station
node scripts/bahn.mjs --search "Wuppertal" [--json]

# Find latest departures from a given station
node scripts/bahn.mjs --departures "Wuppertal Hbf" [--results N] [--json]

# Default: Parse and show live data
echo '<raw Navigator share text>' | node scripts/bahn.mjs --parse [--json]

# With prediction model (transferProb, zugbindungProb)
echo '<text>' | node scripts/bahn.mjs --parse --predict [--json]

# With historical stats from bahn.expert
node scripts/bahn.mjs --parse connections/active.json --stats [--json]

# Both
node scripts/bahn.mjs --parse connections/active.json --predict --stats [--json]

# Find a given journey in timetable
node scripts/bahn.mjs --journey "From" "To" [--date YYYY-MM-DD] [--time HH:MM] [--results N] [--days N] [--json]

# Get current delays
node scripts/bahn.mjs --live --current-leg N [--delay M] connections/active.json [--json]

# Find a specific train by number and category (example: ICE 933)
node scripts/bahn.mjs --category CAT --train NUM [--date YYYY-MM-DD] [--json]

File Layout

scripts/
โ”œโ”€โ”€ bahn.mjs                    โ† thin CLI dispatcher (~60 lines)
โ”œโ”€โ”€ lib/
โ”‚   โ”œโ”€โ”€ commands/             โ† one module per mode
โ”‚   โ”‚   โ”œโ”€โ”€ search.mjs        โ† --search: station lookup
โ”‚   โ”‚   โ”œโ”€โ”€ departures.mjs    โ† --departures: live departure board
โ”‚   โ”‚   โ”œโ”€โ”€ parse.mjs         โ† --parse: connection parsing + enrichment
โ”‚   โ”‚   โ”œโ”€โ”€ journey.mjs       โ† --journey: route search
โ”‚   โ”‚   โ”œโ”€โ”€ live.mjs          โ† --live: real-time transfer check
โ”‚   โ”‚   โ””โ”€โ”€ track.mjs         โ† --track: train tracking
โ”‚   โ”œโ”€โ”€ helpers.mjs           โ† shared helpers (envelope, transfers, assessment)
โ”‚   โ”œโ”€โ”€ data.mjs              โ† source router (IRIS/Vendo/bahn.expert)
โ”‚   โ”œโ”€โ”€ predict.mjs           โ† probability model (opt-in via --predict)
โ”‚   โ”œโ”€โ”€ stats.mjs             โ† delay profiles + historical stats (opt-in via --stats)
โ”‚   โ”œโ”€โ”€ parse.mjs             โ† connection text parser
โ”‚   โ”œโ”€โ”€ format.mjs            โ† output formatter
โ”‚   โ”œโ”€โ”€ messageLookup.mjs     โ† IRIS delay code lookup
โ”‚   โ””โ”€โ”€ sources/
โ”‚       โ”œโ”€โ”€ bahn-expert.mjs   โ† bahn.expert tRPC source
โ”‚       โ”œโ”€โ”€ iris.mjs          โ† IRIS XML source
โ”‚       โ””โ”€โ”€ vendo.mjs         โ† db-vendo-client source

JSON Envelope

All modes support --json:

{
  "mode": "string",
  "timestamp": "ISO8601",
  "connection": { "date", "from", "to", "legs", "transfers" },
  "journeyOptions": { "from", "to", "date", "options" },
  "departures": { "station", "entries" },
  "stations": { "query", "results" },
  "liveStatus": { "currentLeg", "nextTransfer", "zugbindungStatus", "recommendation", "remainingTransfers" },
  "trackStatus": { "train", "from", "to", "stops", "maxDelay", "zugbindungStatus" },
  "assessment": null,
  "errors": [],
  "warnings": []
}

The assessment field is only populated when --predict is used. Without it, assessment is null.

Prediction Model (predict.mjs) โ€” opt-in only

Exponential delay distributions per train category. Only loaded when --predict is passed.

Category Mean delay Cancel rate
ICE 5.0min 5.5%
IC/EC 4.0min 4.0%
RE 2.5min 2.0%
RB 2.0min 1.5%
S 1.5min 1.0%
Bus 3.0min 2.0%

P(Zugbindung triggered) per leg = exp(-20/mean). Overall P(Zugbindung) = 1 - โˆ(1 - P(leg_i โ‰ฅ 20min)).

Coverage

Long-distance (ICE/IC/EC), regional (RE/RB), S-Bahn, buses, and international trains to neighboring countries.

Information

This project is not affiliated in any way with Deutsche Bahn AG, bahn.expert or bahn-vorhersage.

Install via CLI
npx skills add https://github.com/rutkk/openclaw-bahn --skill bahn
Repository Details
star Stars 1
call_split Forks 0
navigation Branch main
article Path SKILL.md
More from Creator