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