DotBahn.Timetables
1.4.0
dotnet add package DotBahn.Timetables --version 1.4.0
NuGet\Install-Package DotBahn.Timetables -Version 1.4.0
<PackageReference Include="DotBahn.Timetables" Version="1.4.0" />
<PackageVersion Include="DotBahn.Timetables" Version="1.4.0" />
<PackageReference Include="DotBahn.Timetables" />
paket add DotBahn.Timetables --version 1.4.0
#r "nuget: DotBahn.Timetables, 1.4.0"
#:package DotBahn.Timetables@1.4.0
#addin nuget:?package=DotBahn.Timetables&version=1.4.0
#tool nuget:?package=DotBahn.Timetables&version=1.4.0
DotBahn - .NET Client for Deutsche Bahn APIs
DotBahn is a collection of .NET client libraries for accessing Deutsche Bahn (DB) APIs. Query train schedules, station details, and facility status directly from your .NET applications.
Available clients:
StaDa: Station data including parking, accessibility, and opening hours.
FaSta: Real-time operational status of elevators and escalators at DB InfraGO AG stations.
Timetables: Scheduled departures and arrivals with real-time delay and platform change information.
This project originated from a personal application. Development follows my own needs rather than a fixed roadmap. Contributions and forks are welcome.
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
Usage
Dependency Injection (Recommended)
All packages integrate seamlessly with ServiceCollection.
// Add Stations/Timetables/Facilities clients
services.AddDotBahnStations(opt => {
opt.ClientId = <your-client-id>;
opt.ApiKey = <your-client-secret>;
opt.BaseEndpoint = new Uri("...");
});
services.AddDotBahnTimetables(opt => {
opt.BaseEndpoint = new Uri("...");
});
services.AddDotBahnFacilities(opt => {
opt.BaseEndpoint = new Uri("...");
});
At least one client must include authorization credentials. Alternatively, configure authorization centrally:
// Add central authorization
services.AddDotBahnAuthorization(opt => {
opt.ClientId = clientId;
opt.ApiKey = clientSecret;
});
Enable request caching to reduce API calls:
// Add Cache
services.AddDotBahnCache(opt => {
opt.DefaultExpiration = TimeSpan.FromSeconds(...);
});
Manual Initialization
Create client instances directly without dependency injection:
var options = new ClientOptions {
BaseEndpoint = new Uri("...")
};
var auth = new AuthorizationOptions {
ClientId = <your-client-id>,
ApiKey = <your-client-secret>
};
var client = new StationsClient(opt, auth);
Authorization
A Deutsche Bahn API key is required. Register and obtain your credentials at the DB API Marketplace.
| Product | Versions 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. |
-
net10.0
- Microsoft.Extensions.Caching.Memory (>= 10.0.1)
- Microsoft.Extensions.Http (>= 10.0.1)
- Microsoft.Extensions.Options (>= 10.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.