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.

an incredibly ugly logo for this package, we need a hexsticker!

an incredibly ugly logo for this package, we need a hexsticker!


You can NOT YET install the released version of nsapi from CRAN with:

But you can install the development version from GitHub with:


  1. What Can I do with the package?
  • You can access the departures from a station, disruptions (planned and unplanned), get travel advise (between stations) and a list of all stations (in the Netherlands and some outside.). In the vignette I’ve described how to use the functions.
  1. I’m getting a curl timeout!
  • Yes… That happens, a lot. The NS website does not return errors but just times you out once in a while. Take a deep breath, retry.
  1. Error Bad request or HTTP 400
  • Your username and password might not be set properly
  1. How do I set a password and username?
  • See Authentication in the vignette


The package is MIT licensed although the information from NS is probably proprietary