• Our new ticketing site is now live! Using either this or the original site (both powered by TrainSplit) helps support the running of the forum with every ticket purchase! Find out more and ask any questions/give us feedback in this thread!

Looking for a good UK's train information API

Status
Not open for further replies.

Rahmat Hidayat

New Member
Joined
29 Oct 2018
Messages
4
Hi everyone,

I'm a freelance developer and currently looking for a good UK's train API, I wanted to capture real-time data on;
  • Causes of train's delay or suspension
  • Which platform numbers the train will stop
  • Length of the carriages
  • etc.
Below are the APIs I have discovered so far (haven't tried it though) was wondering if anybody here has any other recommendations, technical experience, or perhaps other advice on the following
  • Which one is the most accurate/reliable
  • Easiest to understand
  • Cheapest
  • Technical quirks
  • etc.
Please let me know.

List of APIs;
Cheers!
 
Sponsor Post - registered members do not see these adverts; click here to register, or click here to log in
R

RailUK Forums

RailAleFan

Member
Joined
2 Jul 2014
Messages
326
Location
Midlands
Hello Rahmat,

If you haven't come across it already check out the Open Rail Data Wiki for more details of the NR and also Rail Delivery Group (National Rail Enquiries) feeds and APIs;

https://wiki.openraildata.com/index.php/Main_Page

Darwin Push Port ( https://wiki.openraildata.com/index.php/Darwin:Push_Port ) looks like it could be a single source for what you're looking for. There is currently only limited train length data available at version 12 however an update to version 16 is imminent, to include much more service meta data including reservation level etc - check out this thread of the Google Groups page for more info;

https://groups.google.com/d/msg/openraildata-talk/Z8wOISB3u8g/x_OQm5jLBwAJ

Cheers
 
Last edited:

Rahmat Hidayat

New Member
Joined
29 Oct 2018
Messages
4
Hello Rahmat,

If you haven't come across it already check out the Open Rail Data Wiki for more details of the NR and also Rail Delivery Group (National Rail Enquiries) feeds and APIs;

https://wiki.openraildata.com/index.php/Main_Page

Darwin Push Port ( https://wiki.openraildata.com/index.php/Darwin:Push_Port ) looks like it could be a single source for what you're looking for. There is currently only limited train length data available at version 12 however an update to version 16 is imminent, to include much more service meta data including reservation level etc - check out this thread of the Google Groups page for more info;

https://groups.google.com/d/msg/openraildata-talk/Z8wOISB3u8g/x_OQm5jLBwAJ

Cheers
Thank you!
 

trainmania100

Established Member
Joined
8 Nov 2015
Messages
2,717
Location
Newhaven
Word of advice, I'd sign up for the network rail data feeds ASAP
The queue to get the live train times data from NR is about a 6 month wait right now.
There is a queuing system in place as only 500 users at any one time can access the data
I'd recommend you join the queue now as there are around 800 already in there = approx 6 month wait. I've been waiting since June.
 

higthomas

Member
Joined
27 Nov 2012
Messages
1,175
Word of advice, I'd sign up for the network rail data feeds ASAP
The queue to get the live train times data from NR is about a 6 month wait right now.
There is a queuing system in place as only 500 users at any one time can access the data
I'd recommend you join the queue now as there are around 800 already in there = approx 6 month wait. I've been waiting since June.

Why the arbitrary 500 limit?
And are those 800 simply waiting for those 500 to stop using it?
 

Rahmat Hidayat

New Member
Joined
29 Oct 2018
Messages
4
Word of advice, I'd sign up for the network rail data feeds ASAP
The queue to get the live train times data from NR is about a 6-month wait right now.
There is a queuing system in place as only 500 users at any one time can access the data
I'd recommend you join the queue now as there are around 800 already in there = approx 6 months wait. I've been waiting since June.

Thank you for the reply!

A few people have told me that the wait will be long, but I still don't understand the differences between https://datafeeds.nationalrail.co.uk/ and https://datafeeds.networkrail.co.uk/?

What about other sources such as https://api-portal.tfl.gov.uk, are they an independent data provider or third party provider?

Also, I've been told for Darwin the access should be immediate although I don't know whether is enough to obtain the following information;

Train operation
  • The stops' information (platform and station)
  • Timetable
  • Number of carriages
Delay
  • Duration
  • Substitute timetable and stops' information
  • Cause of delay
Is that true?
 

trainmania100

Established Member
Joined
8 Nov 2015
Messages
2,717
Location
Newhaven
Thank you for the reply!

A few people have told me that the wait will be long, but I still don't understand the differences between https://datafeeds.nationalrail.co.uk/ and https://datafeeds.networkrail.co.uk/?

What about other sources such as https://api-portal.tfl.gov.uk, are they an independent data provider or third party provider?

Also, I've been told for Darwin the access should be immediate although I don't know whether is enough to obtain the following information;

Train operation
  • The stops' information (platform and station)
  • Timetable
  • Number of carriages
Delay
  • Duration
  • Substitute timetable and stops' information
  • Cause of delay
Is that true?
I've only used datafeeds.network rail, gives quite a bit of fteedom because it gives you live train running information. Not sure what the others supply but network rail one gives you platforms, passenger TOCs, mostly everything you need.
Tom ciarnes on GitHub has a Cifparser written in PHP which you can import ATCO CIF files, these aren't live train times but they have static timetables including platforming. You don't need the data feeds for the ATCO so just download CIF files and run the importer.

If you want an "out of the box" solution, Phil Wieland openrail system is a great selection of tools. Comes with a basic C++ interface to use the live train data.
I'm using Phil Wieland's open source system but am rewriting the queries and using php instead in the front end.
 

IanXC

Emeritus Moderator
Joined
18 Dec 2009
Messages
6,495
Thank you for the reply!

A few people have told me that the wait will be long, but I still don't understand the differences between https://datafeeds.nationalrail.co.uk/ and https://datafeeds.networkrail.co.uk/?

What about other sources such as https://api-portal.tfl.gov.uk, are they an independent data provider or third party provider?

Also, I've been told for Darwin the access should be immediate although I don't know whether is enough to obtain the following information;

Train operation
  • The stops' information (platform and station)
  • Timetable
  • Number of carriages
Delay
  • Duration
  • Substitute timetable and stops' information
  • Cause of delay
Is that true?

The Network Rail feed comes from a system called TRUST which reflects their position as infrastructure operator - it's an operational system intended for use within the industry. For instance cancellations and amendments to services might or might not be done before or during the trains journey (but should always be completed by the end of the day).

National Rail is a brand name used by all the Train Operating Companies as a public unified face, their Darwin feed is intended for passenger use, and so changes to train running schedules should be completed much more promptly as this feed is used for platform information screens and announcements at stations for instance.

As an example the Network Rail feed will show a service's booked platform until (if in an area with detailed enough information) the signaller sets the route into an alternative platform. National Rail's feed will have this amended as soon as it is known to enable passengers to be on the correct platform before the train arrives (in theory!).
 

Dai Corner

Established Member
Joined
20 Jul 2015
Messages
6,767
The Network Rail feed comes from a system called TRUST which reflects their position as infrastructure operator - it's an operational system intended for use within the industry. For instance cancellations and amendments to services might or might not be done before or during the trains journey (but should always be completed by the end of the day).

National Rail is a brand name used by all the Train Operating Companies as a public unified face, their Darwin feed is intended for passenger use, and so changes to train running schedules should be completed much more promptly as this feed is used for platform information screens and announcements at stations for instance.

As an example the Network Rail feed will show a service's booked platform until (if in an area with detailed enough information) the signaller sets the route into an alternative platform. National Rail's feed will have this amended as soon as it is known to enable passengers to be on the correct platform before the train arrives (in theory!).

How does Darwin get updated before TRUST? Is there somebody looking over the signaller's shoulder and making manual updates? Or is it a case that data from the signalling systems is sent to TRUST and Darwin but the TRUST database isn't updated in real time?
 

greatkingrat

Established Member
Joined
20 Jan 2011
Messages
3,030
As an example the Network Rail feed will show a service's booked platform until (if in an area with detailed enough information) the signaller sets the route into an alternative platform. National Rail's feed will have this amended as soon as it is known to enable passengers to be on the correct platform before the train arrives (in theory!).

The reverse can happen as well. I believe in some cases the National Rail feed hides the platform numbers (particularly at terminus stations), while they can be seen in the Network Rail feed.
 

IanXC

Emeritus Moderator
Joined
18 Dec 2009
Messages
6,495
How does Darwin get updated before TRUST? Is there somebody looking over the signaller's shoulder and making manual updates? Or is it a case that data from the signalling systems is sent to TRUST and Darwin but the TRUST database isn't updated in real time?

The signaller doesn't have a manual way of altering the platform number recorded in Trust, it will only be recorded when ARS sets the route or when the train enters the platform berth. If the signaller (or indeed station staff etc) intends to change the platform they will be in contact with each other by phone or radio, with the TOC staff then entering the platform alteration in Darwin.

The reverse can happen as well. I believe in some cases the National Rail feed hides the platform numbers (particularly at terminus stations), while they can be seen in the Network Rail feed.

Its not really the reverse as such, the Network Rail feed is showing booked platform unless and until something different actually happens, the National Rail feed will be showing the platform, however particular locations are set as 'not to be publicly displayed' - doesn't mean the data isn't in the feed!
 

RailAleFan

Member
Joined
2 Jul 2014
Messages
326
Location
Midlands
Which feeds shows the length of the train and/or the unit number eg 450021

Length where available is in OpenLDBSVWS ("Staff" Version of OpenLDBWS)

http://openldbsv.nationalrail.co.uk/

And also in Darwin Push Port;

https://wiki.openraildata.com/index.php/Darwin:Push_Port

`length` is not widely populated at the moment but hopefully this will change with the upgrade to Push Port v16 coming in December which introduces a new Formations message containing per carriage meta data.

As far as I know, unit allocation information is not anywhere in open data at this time.
 

railwayman27

New Member
Joined
5 Jan 2020
Messages
1
Location
london
Sorry to dig up the old thread, I'm interested in knowing the live location of any currently running trains.. not seeing anything in the Wiki about this. Is there an API with live location updates on every train?
 

trainmania100

Established Member
Joined
8 Nov 2015
Messages
2,717
Location
Newhaven
Sorry to dig up the old thread, I'm interested in knowing the live location of any currently running trains.. not seeing anything in the Wiki about this. Is there an API with live location updates on every train?
Only through signal berths sent out through the network rail open data feeds, you'd need match these berths with longitude and latitude to get the position of the train in the signalling berths (those used on signalling diagrams). Not sure there's any publicly available gps data for services
 

StefanC

New Member
Joined
25 Jun 2020
Messages
3
Location
Birmingham
Not sorry to dig up this thread, but there is a bit of the OP question that still remains not answered and that has me running around in circles.

Is there a feed that would associate a delay code (in accordance with the DAB Delay Attribution Code) with any delayed train?
I know from the open wiki that there is one such association, but only for cancelled trains in the Movement Feed and that isn't of much help. I want to find a way to know, when a train has been delayed, why that was?

I could go as far as to not care about the information in real time, and would be willing to download a file every X days/hours as long as this info is available. Could it be because it's sensitive somehow?
I have played a bit with Darwin (v16) but I couldn't find the information. Maybe I was not looking hard enough.

Any information would be highly appreciated :)
 

RailAleFan

Member
Joined
2 Jul 2014
Messages
326
Location
Midlands
Not sorry to dig up this thread, but there is a bit of the OP question that still remains not answered and that has me running around in circles.

Is there a feed that would associate a delay code (in accordance with the DAB Delay Attribution Code) with any delayed train?
I know from the open wiki that there is one such association, but only for cancelled trains in the Movement Feed and that isn't of much help. I want to find a way to know, when a train has been delayed, why that was?

I could go as far as to not care about the information in real time, and would be willing to download a file every X days/hours as long as this info is available. Could it be because it's sensitive somehow?
I have played a bit with Darwin (v16) but I couldn't find the information. Maybe I was not looking hard enough.

Any information would be highly appreciated :)

Can you post a couple of examples of the codes you're receiving?
 

StefanC

New Member
Joined
25 Jun 2020
Messages
3
Location
Birmingham
Can you post a couple of examples of the codes you're receiving?
In a Movement feed, you would get from time to time a Train Cancel Message looking like this
{"header":{"msg_type":"0002","source_dev_id":"","user_id":"","original_data_source":"","msg_queue_timestamp":"1588841263000","source_system_id":"TRUST"},"body":{"train_file_address":null,"train_service_code":"22109001","orig_loc_stanox":"","toc_id":"65","dep_timestamp":"1588848420000","division_code":"65","loc_stanox":"36151","canx_timestamp":"1588844820000","canx_reason_code":"PD","train_id":"361A25MH07","orig_loc_timestamp":"","canx_type":"ON CALL"}}
Now, according to the OpenRail Wiki, the CANX reason code(Assigned from the Delay Attribution Code document) is the same code that would be used for a delayed Train Movement Message in the Movement feed.
Now, the schema of the Train Movement Message does not contain any delay reason field.

So, my curiosity is: Is there a feed that would be able to give me messages that have a delay_reason_code (similar to the above) associated to a delayed train at a location, with a timestamp?
 

RailAleFan

Member
Joined
2 Jul 2014
Messages
326
Location
Midlands
In a Movement feed, you would get from time to time a Train Cancel Message looking like this
{"header":{"msg_type":"0002","source_dev_id":"","user_id":"","original_data_source":"","msg_queue_timestamp":"1588841263000","source_system_id":"TRUST"},"body":{"train_file_address":null,"train_service_code":"22109001","orig_loc_stanox":"","toc_id":"65","dep_timestamp":"1588848420000","division_code":"65","loc_stanox":"36151","canx_timestamp":"1588844820000","canx_reason_code":"PD","train_id":"361A25MH07","orig_loc_timestamp":"","canx_type":"ON CALL"}}
Now, according to the OpenRail Wiki, the CANX reason code(Assigned from the Delay Attribution Code document) is the same code that would be used for a delayed Train Movement Message in the Movement feed.
Now, the schema of the Train Movement Message does not contain any delay reason field.

So, my curiosity is: Is there a feed that would be able to give me messages that have a delay_reason_code (similar to the above) associated to a delayed train at a location, with a timestamp?
If it's real time you're interested in Train Status (TS) messages on the Push Port feed will sometimes contain a LateReason, here's an example from a few minutes ago;

<Pport ts="2020-06-26T15:19:08.2212496+01:00" version="16.0">
<uR updateOrigin="TD">
<TS rid="202006268809238" uid="X09238" ssd="2020-06-26">
<ns5:LateReason>886</ns5:LateReason>
<ns5:Location tpl="WHYTELF" wta="15:05" wtd="15:05:30" pta="15:05" ptd="15:05">
<ns5:arr at="15:17" atClass="Automatic" src="TD"/>
<ns5:dep at="15:17" atClass="Automatic" src="TD"/>
</ns5:Location>
</TS>
</uR>
</Pport>


The associated text for public display is in the reference data (Amazon/S3) and also on the OpenLDBSVWS reference service endpoint;


You can see the current list here;

Hope this helps!
 

StefanC

New Member
Joined
25 Jun 2020
Messages
3
Location
Birmingham
If it's real time you're interested in Train Status (TS) messages on the Push Port feed will sometimes contain a LateReason, here's an example from a few minutes ago;

<Pport ts="2020-06-26T15:19:08.2212496+01:00" version="16.0">
<uR updateOrigin="TD">
<TS rid="202006268809238" uid="X09238" ssd="2020-06-26">
<ns5:LateReason>886</ns5:LateReason>
<ns5:Location tpl="WHYTELF" wta="15:05" wtd="15:05:30" pta="15:05" ptd="15:05">
<ns5:arr at="15:17" atClass="Automatic" src="TD"/>
<ns5:dep at="15:17" atClass="Automatic" src="TD"/>
</ns5:Location>
</TS>
</uR>
</Pport>


The associated text for public display is in the reference data (Amazon/S3) and also on the OpenLDBSVWS reference service endpoint;


You can see the current list here;

Hope this helps!
RailAleFan, that is exactly what I was looking for! Thank you. I will try and move away from movement feeds and into Darwin Push Port now that I know the info is there.

I might be pushing it a bit, but do you happen to know how often that LateReason code is given out and if there is a reason why some messages have it and some don't?
 

Poggs

Member
Joined
28 Aug 2008
Messages
284
Location
London
It will only be recorded when ARS sets the route or when the train enters the platform berth

All ARS does is set a route - TRUST derives actual platform from berth interpose/step/cancel operations reported to it from a separate system called SMART. A rather large lookup table contains a mapping of these 'moves' to a STANOX and platform, and these are reported to TRUST.

I'm not sure what TRUST reports if you enter a manual report using Simplified Direct Reporting (SDR) - it may just report blank platform data.
 
Status
Not open for further replies.

Top