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.

::Custom Train Times website



Back in the UK

Essentially this is a post to try and prompt me to start blogging a bit again with a bit of an update…

I’ve been back in the United Kingdom for a few months now after deciding earlier this year that almost 10 years in New Zealand was enough, and that it was time for a change in terms of life and work.

I had never really planned to stay as long as I did there, but COVID-19 partly got in the way (I had planned to return to the UK in 2020), and the next time after that I almost returned - late 2021 - also got deferred so as to give other opportunities a go (Unity Software’s take-over of Weta Digital’s R&D department), which didn’t really work out.

So it’s time for a new start back in my native country. Summer this year in the UK was suspiciously good, but autumn’s here now with the more typical weather that brings, but so far I’m not obviously pining for anything back in New Zealand (other than the lack of Sunday trading laws!), which is probably a good sign.


Tags: uk

Trip Photos

Two weeks ago I returned from a trip back to the UK for a few weeks, stopping off in San Francisco for a few days on the way out, and I have almost finished processing the DSLR photos I took, so this is just a quick post containing a single photo each from some of the locations I visited whilst away.

San Francisco:

Photo of San Francisco

Bristol:

Photo of Bristol

Bath:

Photo of Bath Crescent

Cambridge:

s College Cloisters

Chichester:

Photo of Chichester

Needles, Isle Of Wight:

Photo of the Needles, Isle Of Wight



Photos from Trip

I’ve just got back from a trip back to the UK for a few weeks, stopping off in Hong Kong on the way out and Singapore on the way back, which was very enjoyable if also very tiring.

Despite the battery life issue I have with it, the new camera held up well, and I found the Live View functionality very useful for shooting on a tripod and focusing by touching on the screen.

I used this method to tick the box on some (somewhat cliché) location photos in both Hong Kong and Singapore (see below) that I did want to take, and I hope to return to both places in the future to explore more (although the evidence of political rumblings in Hong Kong was fairly apparent).

Hong Kong:

Night photo of Hong Kong

Isle of Wight, UK:

Photo of clock in UK

Singapore:

Photo of Singapore




Archive
Full Index

2026 (4)
2025 (6)
2024 (6)
2023 (7)
2022 (3)
2021 (5)
2020 (4)
2019 (7)
2017 (1)
2016 (2)
2015 (1)
2014 (9)
2013 (10)
2012 (7)


Tags List