Query Deutsche Bahn transport data from v6.db.transport.rest.
brew tap timkrase/tap
brew install dbrest
- Name:
dbrest - One-liner: Query Deutsche Bahn transport data from the DB transport REST API.
- USAGE:
dbrest [global flags] <command> [args]
- Subcommands:
dbrest locations ...dbrest departures ...dbrest arrivals ...dbrest journeys ...dbrest trip ...dbrest radar ...dbrest request ...dbrest help [command]
- Global flags:
-h, --helpshow help and ignore other args--versionprint version to stdout--jsonoutput raw JSON response--plainoutput stable, line-based text (no headers)--base-url <url>override API base URL--timeout <duration>HTTP timeout (default10s)--verboseprint request URL to stderr
- I/O contract:
- stdout: command results (
--jsonfor machine output; default is human text) - stderr: diagnostics, errors, usage, verbose request URLs
- stdout: command results (
- Exit codes:
0success1request/formatting error2invalid usage
- Env/config:
DBREST_BASE_URL(flags override)DBREST_TIMEOUT(flags override)- precedence: flags > env > defaults
- Safety rules:
- read-only API calls, no prompts, no destructive operations
- Examples:
dbrest locations --query "Berlin"dbrest departures --stop 8011160 --results 5dbrest arrivals --stop 8011160 --when "2024-02-01T08:00:00+01:00"dbrest journeys --from Berlin --to Hamburg --results 3dbrest trip --id 1|2|... --line-name ICE 1000dbrest radar --north 52.6 --south 52.4 --west 13.2 --east 13.5 --results 50dbrest request --path /stations --param query=Berlin --json
Run dbrest help <command> for full help. Each subcommand accepts --param key=value to pass through unsupported API query params.
--jsonprints the raw API response JSON for all commands.--plainprints tab-separated, line-based output with no header row. Missing values are-.dbrest request --plainprints raw JSON (same shape as--json) because the response is arbitrary.
Stable --plain columns by command:
locations:id,name,type,latitude,longitude,distance_mdepartures/arrivals:time,line,direction,platform,delay,statusjourneys:departure,origin,arrival,destination,transferstrip:line,stop,arrival,departure,platformradar:line,direction,latitude,longitude
These commands accept a positional fallback for their required flag:
dbrest locations <query>(same as--query)dbrest departures <stop>(same as--stop)dbrest arrivals <stop>(same as--stop)dbrest trip <id>(same as--id)dbrest request <path>(same as--path)
Quality is enforced via:
gofmtformatting (checked inscripts/check.sh)go vetstatic analysisgo test ./...unit testsgolangci-lintwithstaticcheck,errcheck,ineffassign,unconvert,unparam
Run all checks:
./scripts/check.sh
go test ./...