• 0208 1234 422
  • Contact Us
Park Square Consulting
  • ABOUT
    • Our Clients
    • Our Tools
    • Agile Software Development
    • Performance Optimization
    • Responsive Web Design
    • Recruitment & Visa Sponsorship
    • 125 Group
  • PRODUCTS
    • Paxton Net2 JSON API
    • Landlord & Tenant Admin
    • Managing Agent Block Management
    • Social Media Legal Tools
  • .NET CORE
    • .Net Core Config Debugger NEW
    • ARM Build Agent NEW
  • AZURE DEVOPS
    • Build Screen
    • Custom Build Tasks
    • AzDO Command Line Tool
    • ARM Build Agent NEW
  • C# CODE
    • Nuget Gallery
    • .Net Core Config Debugger NEW
    • Gracenote C# API
    • Realtime Trains API
    • Test Data Generators
    • Universal Plug & Play (UPnP)
    • Sky Q Remote Control NEW
    • Super Console
    • C# SQL Bulk Insert
    • JSON REST Api Client
    • SOAP Client
  • SERVERS
    • Our Data Centres
    • Virtual Private Servers
    • Docker Container Hosting
    • Server Colocation
    • Hosted Exchange 2019 Mailboxes
Slider Image

MICROSOFT DEVELOPMENT SPECIALISTS

C#, SQL Server, MVC & Web API

LEARN MORE
Slider Image

AGILE SOFTWARE DEVELOPMENT

Achieve higher quality, lower cost and better maintainability

LEARN MORE
Slider Image

IMPROVE SITE & APP PERFORMANCE

Code analysis, refactoring & SQL Server profiling

LEARN MORE

ParkSquare.RealtimeTrains

BUILD STATUS Continuous Integration Build Status

INSTALLATION

Install-Package ParkSquare.RealtimeTrains

Download

DESCRIPTION

This is a C# API for retrieving timetable, service and realtime train information from Network Rail, National Rail other data sources via the Realtime Trains API.

Documentation

The source data feed is free for personal, academic and educational use. To connect to the Realtime Trains API, you will need access credentials - see here for further information.

First, add the following keys to your web.config or app.config, using the credentials supplied by RTT.


    <add key="Api.Username" value="YOUR-API-USERNAME" />
    <add key="Api.Password" value="YOUR-API-PASSWORD" />
    <add key="Api.Url" value="https://api.rtt.io/api/v1/" />

Now instantiate a new client object:


    var rttClient = new RealtimeTrainsClient();

You can now search for arrivals, departures, or get detailed information on a specific service. For example, to get all arrivals and departures in the near future between Leeds and London Kings Cross, in both directions:


    var rttClient = new RealtimeTrainsClient();
    var arrivals = rttClient.GetDepartures("KGX", "LDS");
    var departures = rttClient.GetDepartures("LDS", "KGX");

For more information, see the Realtime Trains Location Listing documentation.

Once you have results, you can get further detailed information using the service unique Id, and a call to the GetService() method:


    var service = rttClient.GetService(serviceUid, new DateFilter(date.Year, date.Month, date.Day));

Note that 'service Unique IDs' are only unique to a particular day, so you must also pass in the date to this call. For more information, see the Realtime Trains Service Information documentation.

Example Usage

TheTrain.rocks is a web app that uses this Nuget package to allow searching for UK train services, and will reveal the platform numbers before they are announced on the station information boards.

© 2019 Park Square Consulting Limited.
Registered office: 4 Landmark House, 32 Park Place, Leeds, LS1 2SP. Registered in the UK no. 8355358. VAT registration no. 208392410.