ParkSquare.RealTimeTrains 10.0.8

dotnet add package ParkSquare.RealTimeTrains --version 10.0.8
                    
NuGet\Install-Package ParkSquare.RealTimeTrains -Version 10.0.8
                    
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="ParkSquare.RealTimeTrains" Version="10.0.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ParkSquare.RealTimeTrains" Version="10.0.8" />
                    
Directory.Packages.props
<PackageReference Include="ParkSquare.RealTimeTrains" />
                    
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 ParkSquare.RealTimeTrains --version 10.0.8
                    
#r "nuget: ParkSquare.RealTimeTrains, 10.0.8"
                    
#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 ParkSquare.RealTimeTrains@10.0.8
                    
#: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=ParkSquare.RealTimeTrains&version=10.0.8
                    
Install as a Cake Addin
#tool nuget:?package=ParkSquare.RealTimeTrains&version=10.0.8
                    
Install as a Cake Tool

C# UK National Rail Realtime Train Departures, Arrivals & Live Running Information

Build Status

Next Generation API

Realtime Trains announced their next generation API in March 2026. The old service will cease to work on 30 September 2026.

Version 10 onwards of ParkSquare.RealTimeTrains will work only with the next generation API. If you require support for the legacy API, please use an earlier version.

More info is available on Github

Background

C# library for retrieving real time train information from Network Rail, National Rail other data sources via the Realtime Trains API. It also provides accurate data regarding timetables, services, bus replacements and platform information.

Getting Started

The source data feed is free for personal, academic and educational use. To connect to the Realtime Trains API you will need access credentials, which can be obtained by going to the Realtime Trains Developer portal. These credentials are in the form of a username and password, which this library will automatically add to your calls.

The main class you will need is RealTimeTrainsClient. To create one of these, you will need to pass in an HttpClient and an implementation of IRealTimeTrainsClientConfig. It's up to you how you implement IRealTimeTrainsClientConfig, for example you may bind it to entries in your appsettings.config or to secrets in an Azure Key Vault. Here is a simple example with hardcoded values:

public class RealTimeTrainsClientConfig : IRealTimeTrainsClientConfig
{
    public string BaseUrl => "https://data.rtt.io";

    public string Token => "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";

    public string ApiVersion => "2026-03-27"
}

BaseUrl and Token are mandatory. You can generate a token by logging into the RTT Portal. If you want to target a specific version of the API, set that in the ApiVersion property. If you leave it blank, the latest API version will be used by default.

The recommended way to instantiate your RealTimeTrainsClient is to use Dependency Injection. Read about HttpClient dependency injection with .Net Core and then come back. Here is an example of how to register the required dependencies in your project:

services.AddSingleton<IRealTimeTrainsClient, RealTimeTrainsClient>();
services.AddSingleton<IRealTimeTrainsClientConfig, RealTimeTrainsClientConfig>();
services.AddHttpClient();

You can now access the RealTimeTrainsClient by simply adding an IRealTimeTrainsClient to the constructor of the class where you want to use it.

This allows you to search for train services between two stations, get station location static data, and to get detailed timetable and running information on specific services.

This call will retrieve a list of all locations, along with the namespace they belong to. For most purposes, the namespace you need to use is gb-nr. The namespace and location codes are separated by a colon, e.g. gb-nr:LDS. In most cases, a short of long code for a station will work.

var locations = await _client.GetLocationsAsync();

foreach (var location in locations)
{
    Console.WriteLine($"{location.ShortCode} {location.Description}");
}

This call will find all services between Manchester Victoria and Leeds between two dates/times and will include the optional detailed data (if your account is enabled for this):

var services = await _client.GetServicesAsync("gb-nr:MCV", "gb-nr:LDS", new DateTime(2026, 4, 11, 11, 00, 00),
    new DateTime(2026, 4, 11, 11, 30, 00), true);

foreach (var service in services.Services)
{
    if (service.ScheduleMetadata.InPassengerService)
    {
        Console.WriteLine($"{service.ScheduleMetadata.UniqueIdentity} " +
                            $"{origin.TimingPoints.ScheduleAdvertised} {origin.Location.Description} --> " +
                            $"{destination.TimingPoints.ScheduleAdvertised} {destination.Location.Description}");
    }
}

This final example will retrieve detailed service information. Services can be found using either their unique identity, e.g. gb-nr:L01525:2025-10-26 or by individually specifying the namespace, service identity and departure date.

The optional flag to include additional detailed data is set here, which will also fetch the passing points of the service as well as the public calling points.

var serviceDetail = await _client.GetServiceAsync("gb-nr:Y25415:2026-04-11", true);

foreach (var callingPoint in serviceDetail.Service.Locations)
{
    Console.WriteLine($"{callingPoint.Location.PrimaryLongCode} {callingPoint.Location.Description}");
}

For more information, see the Realtime Trains Documentation on Github.

Example App

A live demo of this library can be found at thetrain.rocks.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.0.8 104 4/15/2026
8.0.1 315 6/22/2024
8.0.0 200 6/22/2024
3.0.17 580 2/9/2023
3.0.14 633 8/19/2022
3.0.13 746 5/30/2022
3.0.11 568 11/22/2021
3.0.9 701 5/16/2021
3.0.8 630 4/19/2021
2.1.3 946 7/2/2019
2.1.2 850 6/5/2019
2.1.1 876 6/4/2019
2.1.0 876 6/4/2019
Loading failed