trainR: An Interface to the National Rail Enquiries Systems


The goal of trainR is to provide a simple interface to the National Rail Enquiries (NRE) systems. There are few data feeds available, the simplest of them is Darwin, which provides real-time arrival and departure predictions, platform numbers, delay estimates, schedule changes and cancellations. Other data feeds provide historical data, Historic Service Performance (HSP), and much more. trainR simplifies the data retrieval, so that the users can focus on their analyses. For more details visit


You can install the released version of trainR from CRAN with:


And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("villegar/trainR", "dev")


Before starting to retrieve data from the NRE data feeds, you must obtain an access token. Visit the following website for details:

Once you have received your access token, you have to store it in the .Renviron file; this can be done by executing the following command:


This will open a text file, .Renviron, add a new line at the end (as follows):


<token> should be replaced by the access token obtained from the NRE. Save the changes and restart your R session.

You only need to perform this configuration once.

Example (Last rendered on 2022-10-01 20:04)

Load trainR to your working environment:


Arrivals board at Reading Station (RDG)

rdg_arr <- trainR::GetArrBoardRequest("RDG")
## Reading (RDG) Station Board on 2022-10-01 20:04:33

Departures board at Reading Station (RDG)

rdg_dep <- trainR::GetDepBoardRequest("RDG")
## Reading (RDG) Station Board on 2022-10-01 20:04:36