NimTrains is an extremely quick and simple command-line interface and Nim package to get realtime UK train information from Worldline's "Tiger" train API. It's a like-for-like Nim port of my Python project PyTrains, but as you'll see when you read on, it has some huge advantages over its Python counterpart.
Start by downloading a binary from the releases page and adding it to your PATH so you have access to the nimtrains
command from any command prompt.
To view the departures from a station, you can run nimtrains <station name or CRS code>
, for example nimtrains BHM
or nimtrains "birmingham new street"
. If the station name has any spaces in it, you'll need to put it in quotation marks.
You'll notice that each service has an ID on the left. To see more information about a specific service from the station, run nimtrains <station name or CRS code> [-i, --id] <service ID>
, for example nimtrains PNZ -i 1
or nimtrains penzance --id 3
.
To get information about the next train to a certain destination, you can run nimtrains <origin station> [-d, --dest] <destination station>
. For example, nimtrains PAD -d BRI
or nimtrains "london paddington" --dest "bristol temple meads"
.
Comparison with PyTrains
You might've seen my other project, PyTrains, which provides an identical CLI to this one, written in Python. While these two projects both have the same functionality, it's easy to determine which you should use using this table:
PyTrains | NimTrains |
---|---|
โ๏ธ Provides a CLI | โ๏ธ Provides a CLI |
โ๏ธ Provides an easy-to-use Python library | โ๏ธ Provides an easy-to-use Nim package |
โ Is relatively slow | โ๏ธ Is 12x faster than PyTrains (excluding request time) |
โ๏ธ Doesn't require a binary and is therefore smaller | โ Requires a ~500KB binary to be installed |
โ Requires Python (>100MB) and 6 dependencies | โ๏ธ No dependencies, works out-of-the-box |
In short, use PyTrains if you want access to the Python library to use in your own code, but if you're only looking for a CLI to access realtime UK train information, NimTrains' massive speed advantage makes it a better option.
It's very easy to build NimTrains yourself as it doesn't have any dependencies. You can use the supplied make.bat
file to build for release or run nimble build
to use Nimble.