Query Dutch Railways (NS) for train departures, trip planning, disruptions, and station search via the trein CLI.
A CLI for the NS (Dutch Railways) API with real-time departures, trip planning, disruptions, and station search.
npm (recommended):
npm i -g trein
Or download a standalone binary from GitHub Releases.
Get an API key from https://apiportal.ns.nl/ and set it:
export NS_API_KEY="your-api-key"
Or create ~/.config/trein/trein.config.json:
{ "apiKey": "your-api-key" }
trein departures "Amsterdam Centraal"
trein d amsterdam
trein d amsterdam --json # structured output
trein trip "Utrecht" "Den Haag Centraal"
trein t utrecht denhaag --json
trein disruptions
trein disruptions --json
trein stations rotterdam
trein s rotterdam --json
trein alias set home "Amsterdam Centraal"
trein alias set work "Rotterdam Centraal"
trein alias list
trein d home # uses alias
--json flag for all commands to get structured output for parsing