Files

2.3 KiB

name, description, homepage, metadata
name description homepage metadata
trein Query Dutch Railways (NS) for train departures, trip planning, disruptions, and station search via the trein CLI. https://github.com/joelkuijper/trein
bot
emoji requires primaryEnv install
🚆
bins env
trein
NS_API_KEY
NS_API_KEY
id kind package bins label
npm node trein
trein
Install trein (npm)
id kind url bins label os
download-mac-arm download https://github.com/joelkuijper/trein/releases/latest/download/trein-darwin-arm64
trein
Download (macOS Apple Silicon)
darwin
id kind url bins label os
download-mac-x64 download https://github.com/joelkuijper/trein/releases/latest/download/trein-darwin-x64
trein
Download (macOS Intel)
darwin
id kind url bins label os
download-linux download https://github.com/joelkuijper/trein/releases/latest/download/trein-linux-x64
trein
Download (Linux x64)
linux

trein - Dutch Railways CLI

A CLI for the NS (Dutch Railways) API with real-time departures, trip planning, disruptions, and station search.

Install

npm (recommended):

npm i -g trein

Or download a standalone binary from GitHub Releases.

Setup

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" }

Commands

Departures

trein departures "Amsterdam Centraal"
trein d amsterdam
trein d amsterdam --json  # structured output

Trip Planning

trein trip "Utrecht" "Den Haag Centraal"
trein t utrecht denhaag --json

Disruptions

trein disruptions
trein disruptions --json
trein stations rotterdam
trein s rotterdam --json

Aliases (shortcuts)

trein alias set home "Amsterdam Centraal"
trein alias set work "Rotterdam Centraal"
trein alias list
trein d home  # uses alias

Tips

  • Use --json flag for all commands to get structured output for parsing
  • Station names support fuzzy matching (e.g., "adam" -> "Amsterdam Centraal")
  • Aliases are stored in the config file and can be used in place of station names