The Dutch National Railway service (NS; Nederlandse Spoorwegen) has an API where we can query for travel advise, see the current trains on a given station, see if there is any delays or work on the tracks and NS also provides a list with geolocation of all the stations.
The goal of nsapi is to make it easy to gather data from the NS API. The package returns data frames for every response.
You can NOT YET install the released version of nsapi from CRAN with:
But you can install the development version from GitHub with:
This is a basic example which shows you how you get travel information:
treinplanner <- get_travel_advise(
fromStation = "Leiden Centraal",
toStation = "Utrecht Centraal",
departure = TRUE,
yearCard = TRUE,
previousAdvises = 1,
nextAdvises = 1)
treinplanner
#> Melding AantalOverstappen GeplandeReisTijd ActueleReisTijd
#> 1 NA 0 0:42 0:42
#> 2 NULL 1 0:56 0:56
#> 3 NA 0 0:42 0:42
#> 4 NA 1 0:56 0:56
#> VertrekVertraging AankomstVertraging Optimaal GeplandeVertrekTijd
#> 1 <NA> <NA> FALSE 2018-08-04 09:22:00
#> 2 <NA> <NA> FALSE 2018-08-04 09:23:00
#> 3 <NA> <NA> TRUE 2018-08-04 09:52:00
#> 4 <NA> <NA> FALSE 2018-08-04 09:53:00
#> ActueleVertrekTijd GeplandeAankomstTijd ActueleAankomstTijd
#> 1 2018-08-04 09:22:00 2018-08-04 10:04:00 2018-08-04 10:04:00
#> 2 2018-08-04 09:23:00 2018-08-04 10:19:00 2018-08-04 10:19:00
#> 3 2018-08-04 09:52:00 2018-08-04 10:34:00 2018-08-04 10:34:00
#> 4 2018-08-04 09:53:00 2018-08-04 10:49:00 2018-08-04 10:49:00
#> Status ReisDeel
#> 1 VOLGENS-PLAN NS, Inte....
#> 2 NIET-MOGELIJK c("NS", ....
#> 3 VOLGENS-PLAN NS, Inte....
#> 4 VOLGENS-PLAN c("NS", ....