DotBahn is a collection of unofficial .NET client packages for accessing Deutsche Bahn (DB) APIs. Query train schedules, station details, and facility status directly in your application. It also provides convenience features like timetable merging, fluent queries and some additional properties. All libraries are AOT compatible and trimmable.
| API | Description |
|---|---|
| Stations (StaDa) | Station data including parking, accessibility, and opening hours. |
| Facilities (FaSta) | Real-time operational status of elevators and escalators at stations. |
| Boards (OpenBoards) | Scheduled departures and arrivals with real-time delay and platform change information. |
Caution
Deutsche Bahn is shutting down the Timetables API. It entered parallel operation in November 2026 and is scheduled for shutdown around mid-2027. There is a replacement package with DotBahn.Boards that uses the new OpenBoards API.
Install the packages you need from NuGet or GitHub Packages:
dotnet add package DotBahn.Boards
dotnet add package DotBahn.Stations
dotnet add package DotBahn.Facilities
# Optional; see below for further details.
dotnet add package DotBahn.TelemetryNote
All client packages depend on DotBahn.Common, which provides cross-cutting abstractions such as authorization, base client infrastructure, and shared models. It is installed automatically as a transitive dependency.
All packages integrate seamlessly with IServiceCollection. Each client comes with a default endpoint, override only for custom proxies:
// Register clients
services.AddDotBahnStations();
services.AddDotBahnBoards();
services.AddDotBahnFacilities();
// Configure authorization (required for API access)
services.AddDotBahnAuthorization(opt => {
opt.ClientId = clientId;
opt.ApiKey = clientSecret;
});
...
// Optional: override default endpoints
services.AddDotBahnStations(opt => {
opt.BaseEndpoint = new Uri("https://custom-proxy.example.com/stada");
});Create client instances directly without dependency injection. Each client creates and owns its own HttpClient:
using var client = new StationClient(
new ClientOptions {
BaseEndpoint = new Uri("https://apis.deutschebahn.com/db-api-marketplace/apis/station-data/v2/")
},
new AuthorizationOptions {
ClientId = clientId,
ApiKey = clientSecret
});All clients emit OpenTelemetry-compatible traces and metrics using the built-in ActivitySource and Meter APIs. The client packages themselves have no OpenTelemetry dependency. Enable collection with the DotBahn.Telemetry package, which registers the source and meter with your OpenTelemetry providers:
// OpenTelemetry configuration
services.AddOpenTelemetry()
.WithTracing(tracing => tracing.AddOtlpExporter())
.WithMetrics(metrics => metrics.AddOtlpExporter());
// Add dotbahn specific activites
services.AddDotBahnTelemetry();A Deutsche Bahn API key is required. Register and obtain your credentials at the DB API Marketplace.
Warning
These packages only consume the credentials you provide for API authentication. They do not create, register, or manage credentials on your behalf.
All samples take DB credentials via --client / --secret or, more conveniently, the DOTBAHN_CLIENT / DOTBAHN_SECRET environment variables.
Terminal departures board for DB timetable services. Shows customer-facing train names (service line or trip number), planned and actual times, delays, platforms, destinations, and via stops. Optional category filter, upstream time window and machine-readable JSON output.
Note
If you are just here to use the departure monitor as a standalone tool on your system, there is also a packaged RPM on the Open Build Service for that.
Interactive terminal application for exploring DB station details. Search by name and navigate results with arrow keys. Shows station category, identifiers (EVA/RIL100), address, coordinates, regional area, available services, and real-time elevator/escalator status.
The package DotBahn.Ai is an early exploration of integrated AI tool support. It is experimental and has no current development priority. If you have experience with .NET AI integrations, tool calling or related designs, feel free to contribute.
However, there is a minimal interactive chatbot sample that uses a local Ollama model with these tools. It defaults to qwen3:4b at http://localhost:11434/v1; override with --model and --endpoint.



