DotBahn.Common 2.1.0

dotnet add package DotBahn.Common --version 2.1.0
                    
NuGet\Install-Package DotBahn.Common -Version 2.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DotBahn.Common" Version="2.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DotBahn.Common" Version="2.1.0" />
                    
Directory.Packages.props
<PackageReference Include="DotBahn.Common" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DotBahn.Common --version 2.1.0
                    
#r "nuget: DotBahn.Common, 2.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DotBahn.Common@2.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DotBahn.Common&version=2.1.0
                    
Install as a Cake Addin
#tool nuget:?package=DotBahn.Common&version=2.1.0
                    
Install as a Cake Tool

<img src="docs/images/logo-256x256.png" width=128 alt="logo">

DotBahn - .NET Client for Deutsche Bahn APIs

NuGet NuGet

NuGet NuGet NuGet

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 additional properties.

API Description
Stations (StaDa) Station data including parking, accessibility, and opening hours.
Facilities (FaSta) Real-time operational status of elevators and escalators at stations.
Timetables Scheduled departures and arrivals with real-time delay and platform change information.

Table of Contents

Install

Install the packages you need from NuGet or GitHub Packages:

dotnet add package DotBahn.Timetables
dotnet add package DotBahn.Stations
dotnet add package DotBahn.Facilities

# Optional; see below for further details.
dotnet add package DotBahn.Telemetry

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.

Usage

All packages integrate seamlessly with IServiceCollection. Each client comes with a default endpoint, override only for custom proxies:

// Register clients
services.AddDotBahnStations();
services.AddDotBahnTimetables();
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");
});

Manual Initialization

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
    });

Telemetry

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();

Authorization

A Deutsche Bahn API key is required. Register and obtain your credentials at the DB API Marketplace.

These packages only consume the credentials you provide for API authentication. They do not create, register, or manage credentials on your behalf.

Samples

ICE Monitor

A terminal-based departure board for ICE trains at a given station. Displays train numbers, scheduled and actual departure times, platforms, destinations, and routes. Highlights delays and platform changes.

dotnet run --project samples/DotBahn.Samples.IceMonitor -- <EVA> <your-client-id> <your-client-secret>

<img src="https://i.imgur.com/Z3fKMo5.png" width=500>

Station Browser

An 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.

dotnet run --project samples/DotBahn.Samples.StationBrowser -- <SearchName> <your-client-id> <your-client-secret>

<img src="https://i.imgur.com/XWwBVr2.png" width=500>

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on DotBahn.Common:

Package Downloads
DotBahn.Timetables

.NET client for DB Timetables API.

DotBahn.Stations

.NET client for DB StaDa API.

DotBahn.Facilities

.NET client for DB FaSta API.

DotBahn.Telemetry

OpenTelemetry registration adapters for DotBahn client packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.1.0 118 9/13/2026
2.0.3-preview.16 81 9/2/2026
2.0.2 164 7/28/2026
2.0.1 161 6/18/2026
2.0.0 175 6/18/2026 2.0.0 is deprecated because it is no longer maintained.