使用 Deutsche Bahn API (v6.db.transport.rest) 规划德国及欧洲的行程,涵盖 ICE、IC、区域列车、城市快线 (S‑Bahn)、地铁 (U‑Bahn)、有轨电车、公交车等。
Plan journeys across Germany and Europe via the Deutsche Bahn REST API. Covers ICE, IC/EC, regional trains, S-Bahn, U-Bahn, trams, buses, and ferries — with real-time delays.
No API key required. Free public API. Rate limit: 100 req/min.
scripts/db-travel.py — standalone Python 3 CLI, no dependencies beyond stdlib.
bash
# Search for stations/stops
python3 scripts/db-travel.py search "Berlin Hbf"
# Plan a trip (place names auto-resolve)
python3 scripts/db-travel.py trip "Berlin Hbf" "Munich Hbf"
# Depart at specific time
python3 scripts/db-travel.py trip "Berlin Hbf" "Flughafen BER" --time "2025-03-01T10:00:00+01:00"
# Arrive by a specific time
python3 scripts/db-travel.py trip "Hamburg" "Berlin" --time "2025-03-01T14:00:00" --arrive
# Departure board
python3 scripts/db-travel.py departures 8011160 --limit 10
# Arrival board
python3 scripts/db-travel.py arrivals 8011160 --duration 60
# Station details
python3 scripts/db-travel.py stop 8011160
All output is JSON.
Use search to find IDs. Some common ones:
801116080002618002549800010580002078089110The API returns product types: nationalExpress (ICE), national (IC/EC), regionalExpress, regional, suburban (S-Bahn), subway (U-Bahn), tram, bus, ferry, taxi.
When presenting trip results to users: