Custom UK live Train Times webpage
Now that I’m commuting regularly again using UK public transport, given the occasional (at least so far for me on the days I commute!) delays and cancellations to services that tend to happen, I was looking for a simple iOS app or website that would allow me to very easily see at a glance what the trains for the next hour or so looked like in terms of possible delays or cancellations.
There are a plethora of train and transport apps out there for iOS - and similarly there are many websites which technically provide that information - but unfortunately, at least for the ones I’ve looked at, they seem to either have adverts, large banners requiring scrolling to see the results, repeated cookie popups, or no ability to bookmark a ‘favourite’ journey and jump straight to that without selecting the ‘favourite’ destination first and running a search.
It’s very likely there probably is a perfect app / website providing what I want out there that I just haven’t found yet, but I thought “How hard can this be?”, on the assumption that if the raw train data is available for free, it should be trivial to knock something basic up.
National Rail provides https://raildata.org.uk/, which includes several HTTPS APIs for querying live data of various things, including departure board information, which can be further filtered down with parameters (i.e. stations being stopped at). You have to register and sign up to access the API endpoint, but it’s free otherwise, and while some of the spec / documentation for some of the APIs is arguably sometimes a little different to what is actually needed and returned (the schema seems to vary a little on occasion! - sometimes platform information is totally missing at the schema level), I did manage to get the information I wanted from it, which does seem to (almost always) effectively be as live as the train departure boards in the stations, and contains estimated arrival times when trains are delayed.
So I’ve now got an incredibly simple setup where a GET request to my page triggers a direct synchronous request internally to the raildata.org.uk API endpoint to fetch the data (which is a bit unorthodox, but as I’m the only user and the response time of the API is generally < 300 ms, it works well enough), the data is extracted from the JSON response and put into an HTML table response and returned to the user agent, essentially providing me with live train data in a format I completely control.
I’ve also tailored the layout for my iPhone 13 mini screen size, and built in the station pair (as I only need one), which automatically switches over at lunchtime ready for the journey home later in the day. So I can just use a single constant URL to always get the train information I need for my next commute journey.
In the future I may decide to architect things a bit more sensibly if there are additional features or (very unlikely) other users of the page, and I may look into bus time information as well to see if free live data is available for that, but for the moment this works perfectly for my use-case, and I’m very happy with it, despite its simplicity.









