Query the Dutch railways about your routes, getting info on delays and more. See below for the syntax and example output.
Installation
From PyPI
Assuming you already are inside a virtualenv:
pip install nsapi
From Git
Create a new virtualenv (if you are not already in one) and install the necessary packages:
git clone https://github.com/aquatix/ns-api.git
cd ns-api
mkvirtualenv ns-api
pip install -r requirements.txt
Development in Docker
Git clone this repository, use vscode & docker to remote open in a dev container as explained in this howto.
As part of ns-notifications
Alternatively, follow the installation instructions of ns-notifications, which makes extensive use of this library to serve notifications to for example a smartphone. The requirements of both packages can be installed in the same ns-notifications one mentioned in the project; ns-api will be installed through pip from PyPI.
Home Assistant
The very useful Home Assistant home automation software includes an integration for the ns-api. Be sure to check it out.
Also take a look at nsmaps
Bart Römgens created a fascinating contour map called nsmaps based on ns-api. It visualises Dutch railways travel information with OpenLayer 3 contour maps to show how long it takes to get somewhere in the Netherlands by train and bicycle.
Example application
For example, I use the library to push notifications about my route to my phone through Pushbullet. The program I use to do this has its own repository: ns-notifications.
NS API key
To actually be able to query the Nederlandse Spoorwegen API, you need to subscribe. This immediately gives you a primary and secundary key you need for access.
The library uses the reisinformatie API. Here you can try the API for yourself (and look up station names, but the library has the get_stations() function for this too).
The API portal also provides statistics on usage and errors.
Metadata
Release files for nsapi 3.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| nsapi-3.2.1.tar.gz | 13.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nsapi-3.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 25.6 kB
Release files / nsapi-3.2.1.tar.gz
| Download URL | nsapi-3.2.1.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c6c7565c6876ec81cb7561d6bc48b9b6242b1fc4b33178f4eae9b9a39b9667fa
|
|
BLAKE2b-256 checksum How to use checksums |
2b6b59c11581d9a866c680e59ef1c53e65c9a41ea6b56c22204fbe67270f654b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / nsapi-3.2.1-py3-none-any.whl
| Download URL | nsapi-3.2.1-py3-none-any.whl |
|---|---|
| Size | 11.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
927e0777ac2d49c9f8d141511471e1cd6589d9d2a36bf16de06ac5b2e1b40044
|
|
BLAKE2b-256 checksum How to use checksums |
06a7f20d3039c04c84ef35972ac99f97c5fe02a0718f75e096834fdda8411a0d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for nsapi 3.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.