Skip to main content

CLI tool to obtain schedule info from the dutch railway services

Project description

PyPI Version Python Version CI/CD

nstimes

Find your next train home while you are in CLI. I used the Dutch Railway Services (Nederlandse Spoorwegen) API to make myself this tool.

Usage:

$ nstimes [OPTIONS] COMMAND [ARGS]...

Options:

  • --version: Print version info
  • --install-completion: Install completion for the current shell.
  • --show-completion: Show completion for the current shell, to copy it or customize the installation.
  • --help: Show this message and exit.

Commands:

  • journey: Provide train type, platform and departure...
  • update-stations-json: Generate stations lookup

nstimes journey

Provide train type, platform and departure times of an A -> B journey

Usage:

$ nstimes journey [OPTIONS]

Options:

  • --start TEXT: Start station [required]
  • --end TEXT: Stop station [required]
  • --token TEXT: Token to talk with the NS API [env var: NS_API_TOKEN; required]
  • --time TEXT: Time to departure (%H:%M) [default: 12:19]
  • --date TEXT: Date to departure (%d-%m-%Y) [default: 15-10-2023]
  • --printer-choice [table|ascii]: [default: ascii]
  • --help: Show this message and exit.

nstimes update-stations-json

Generate stations lookup, should not be neccesary

Usage:

$ nstimes update-stations-json [OPTIONS]

Options:

  • --token TEXT: Token to talk with the NS API [env var: NS_API_TOKEN; required]
  • --path TEXT: Token to talk with the NS API [env var: NS_API_TOKEN; default: /home/erik/dev/ns_cli/nstimes/stations.json]
  • --help: Show this message and exit.

Installation

To install, run the following:

pip install nstimes

To verify, run:

nstimes --version

To install auto-completion, run:

nstimes --install-completion

In order for autocomplete to work, one might need to add this to their .zshrc:

echo -e "\ncompinit -D\n" | tee -a ~/.zshrc
source ~/.zshrc # Reload shell

Obtaining NS token Create an account at the NS API portal. Then create a token here.

Add the token to your shell, for zsh:

echo -e "\nexport NS_API_TOKEN=****\n" | tee -a ~/.zshrc
source ~/.zshrc # Reload shell

Printers By default, this tool prints in ASCII, e.g.:

IC  p. 12 in  4 min (21:37) -> (21:50)
IC  p. 12 in 16 min (21:49) -> (22:02)
SPR p.  4 in 17 min (21:50) -> (22:10)
IC  p. 12 in 34 min (22:07) -> (22:20)
IC  p. 12 in 46 min (22:19) -> (22:32)
SPR p.  4 in 47 min (22:20) -> (22:40)

If you use the --printer-choice table option it prints like:

    Journeys from Utrecht Centraal -> Amersfoort Centraal at
                        24-01-2024 21:32
┏━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┓
┃ Train  Platform  Leaves in  Departure time  Arrival time ┃
┡━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━┩
│ IC           12      4 min         (21:37)       (21:50) │
│ IC           12     16 min         (21:49)       (22:02) │
│ SPR           4     17 min         (21:50)       (22:10) │
│ IC           12     34 min         (22:07)       (22:20) │
│ IC           12     46 min         (22:19)       (22:32) │
│ SPR           4     47 min         (22:20)       (22:40) │
└───────┴──────────┴───────────┴────────────────┴──────────────┘

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nstimes-0.4.8.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nstimes-0.4.8-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file nstimes-0.4.8.tar.gz.

File metadata

  • Download URL: nstimes-0.4.8.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.0 Linux/6.2.0-1018-azure

File hashes

Hashes for nstimes-0.4.8.tar.gz
Algorithm Hash digest
SHA256 d3bc0013fb461295593d14a1b904350eda7d3d8d93ad47f4435e17486f25ca21
MD5 5db92b764fd5aef43b2dab3b9af1bc46
BLAKE2b-256 05176f4462e2d97b73aec696ad1f4e5054dfbbeb2b0b0bf261172e349bb04e25

See more details on using hashes here.

File details

Details for the file nstimes-0.4.8-py3-none-any.whl.

File metadata

  • Download URL: nstimes-0.4.8-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.0 Linux/6.2.0-1018-azure

File hashes

Hashes for nstimes-0.4.8-py3-none-any.whl
Algorithm Hash digest
SHA256 177787dfd43567f9bae3dcb1837eccd597195465a7c259b165c423a9d2aff4ae
MD5 e69c7324dab882b44ed6545ee4868e08
BLAKE2b-256 e9ea32500269f598fa3096d3a57f4d78ca25c6a1cc276ddd8ab3323638b2bc8a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page