Displaying public transport information in the terminal

For a long time I have wanted some way to see, at a glance, information about various different modes of public transport in my area, preferably alongside some other useful information like weather. For example, from my house in London I can often take a train, tube or bus to my destination, and which one is best will depend on the time of day and whether there are delays or disruptions, etc. So a dashboard that gives me all of that information will let me easily decide how to go about the journey. Both Trasport for London (TfL) and National Rail provide a lot of helpful information through public APIs, but I wanted a way to show it all together.

Initially I tried to create such a dashboard myself using simple HTML and CSS, but web UI programming isn't something I'm very good at or particularly enjoy. So I looked at a number of selfhosted dashboard solutions. These are primarily intended for system monitoring, but some of them are extensible. The most promising one I found was Homepage, which looks great and can be extended with custom widgets, which are built using React. Homepage also provides a proxy object to help query API endpoints, but it seems to be intended for use with a basic JSON REST API with static endpoints (where request details are specified using GET parameters). Some of the APIs I would be accessing are not structured in this way - for example, the National Rail API uses SOAP.

Homepage - A modern, fully static, fast, secure fully proxied, highly customizable application dashboard

While trying to think how I could integrate these different APIs with Homepage's widget system, I realised that since all of the information I am looking for is very simple textual information, perhaps the terminal would be the best way to display it. It is minimalist, simple to programme for and available on pretty much any Linux system (and others too, but Linux is what I care about). I looked around for existing terminal dashboard applications and soon found `wtfutil`.

WTF - the terminal dashboard

wtfutil is written in Go, and can be extended with custom widgets. However, it also provides a widget type called `cmdrunner`, which periodically calls a shell script and displays the output within wtfutil. I decided that in the first instance I would write a standalone application that prints the relevant information to the command line, which could then be used within a cmdrunner widget. This would be simpler and would also allow me to re-use the code elsewhere if I wanted.

And so I wrote `bptt` (British Public Transport in the Terminal), which does just that. I wrote bptt in Go, mainly as I thought it would be a good opportunity to get to know the language (which I haven't used before) but also so that it would be easier to integrate directly into wtfutil in future if I wanted. Currently, bptt can display information about various modes of transport operated by TfL (tubes, buses, Santander bikes, Thames Clippers, etc) as well as National Rail departures. It can also display the air quality index for a given city.

bptt - British Public Transport in the Terminal

bptt's output can be configured in various ways using command line flags (or a TOML configuration file). For example, it can use colour in its output (using ANSI escape codes) or output can be of a fixed size and shape (ie, number of rows and the size of each column). The output customisation options are primarily intended to make it display nicely in a fixed-size window such as a wtfutil widget.

Because bptt is mainly just interfacing with various APIs, you may need to get your own API keys to use it. Currently the TfL functions will work without an API key, but a key would be recommended for heavy use to ensure you don't get blocked or rate limited. The other APIs need a key. You can get yours at:

TfL API portal (to get a TfL API key)
Rail Data Marketplace (to get a National Rail Enquiries API key)
WAQI data platform (to get a WAQI API key)

The documentation for bptt, including an example of how to use it within wtfutil, is included in the repo, so I won't go into it here. It was a fun little project, and a good opportunity to learn a bit about Go. I wouldn't say I love all the design choices the Go team have made, but the simplicity of the language meant it was quite easy to pick up over the course of a few days.

The next step for me will be figuring out how best to display the dashboard within my home. I have a Raspberry Pi hooked up to my TV that I think could be an easy solution. But I am also considering getting a basic LCD display to use with a spare Raspberry Pi Zero I have lying around.

I would also like to add more data sources to bptt. An example would be weather information. wtfutil already has a weather widget, but I could add the functionality to bptt in future to have more control over the weather data displayed (for example, I would like to be able to see the current/predicted UV index which wtfutil's standard weather widget does not support).

I was also considering integrating bptt with the Traveline API, which could show live bus departure times for certain areas outside London. However, the process of obtaining an API key for that is a bit cumbersome (involving signing a licence agreement with Traveline) and given that I don't have a pressing need for that data I decided not to implement it at this stage.

Traveline NextBuses API

Hopefully some of you find bptt (or the other information provided here) useful!

Displaying public transport information in the terminal was published on 2025-08-17

Return to index