Jump to content

NS (Nederlandse Spoorwegen) Train schedule for Alfred


Recommended Posts

NS (Nederlandse Spoorwegen) Train schedule for Alfred

Alfred workflow for getting NS Train schedule.

image

Getting started

Prerequisites

Project requires Python 3.8+ to run, which is not included by default with macOS. You can install Python 3 using this guide.

 

⚠️ Make sure to get API key from https://apiportal.ns.nl/ and set it as workflow environment variable NS_APIKEY during the installation.

Downloading & Installing

Download NS_Schedule.alfredworkflow file from the latest release at this project's Github Releases page and open it with Alfred. Change the value of NS_APIKEY variable to the value you've received from NS at the Prerequisites step.

How to Use

Open Alfred and type ns and names of two train stations you want to see schedule for. Workflow will display list of upcoming trains for the route you have specified. Pressing Enter on a displayed item will open it on NS website, so you can get more details.

animation

Built With

Feedback & Contributions

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Link to comment

Welcome @Artemy,

 

19 minutes ago, Artemy said:

Project requires Python 3.8+ to run, which is not included by default with macOS. You can install Python 3 using this guide.

 

That is not necessary. You are just calling python3, so if the user doesn’t have it macOS will try to run /usr/bin/python3 which will show a GUI prompt to install the Developer Tools (which is done anyway when installing Homebrew) and it will then just work on consecutive runs. The version macOS adds is 3.8.9.

Link to comment
21 minutes ago, vitor said:

Welcome @Artemy,

 

 

That is not necessary. You are just calling python3, so if the user doesn’t have it macOS will try to run /usr/bin/python3 which will show a GUI prompt to install the Developer Tools (which is done anyway when installing Homebrew) and it will then just work on consecutive runs. The version macOS adds is 3.8.9.

thanks for the tip!

I thought about this when I upgraded the workflow to Python 3, but found explaining the dependency requirement in this way more reliable and honest.

Link to comment
  • 4 months later...

New version release: 3.1

Changelog:

  • Support stations with spaces in names

For stations with spaces in names use `_` (underscore) instead of space inside the name, e.g. for trains between Den Haag Centraal and Utrecht Leidsche Rijn type `utrecht_leidsche_rijn den_haag_centraal`

image.thumb.png.219747717a11150ad25fb7df9aaf7d97.png

 

Download link

 

Thanks to Github user @Cedrick84 for the contribution

Edited by Artemy
Link to comment

Wouldn’t it make sense to instead use a comma to separate station names always? As in: ns amsterdam, rotterdam and ns den haag centraal, utrecht leidsche rijn. Maybe names with spaces are rare enough that the underscore makes more sense, just pointing it out in case it wasn’t considered.

Link to comment

Hi,

I like the idea of this Alfred Workflow but I don't get it to work.

Which API key do I have to use?

Here are the various APIs listed: https://apiportal.ns.nl/products

I used the key of https://apiportal.ns.nl/products/NsApp but when I try the Alfred search, I get following error message: Can't parse server response. 

Am I using the key of the right NS product?

Thanks

 

Screenshot 2023-01-04 at 11.58.28.png

Edited by KorteAnton
Link to comment
9 hours ago, KorteAnton said:

Hi,

I like the idea of this Alfred Workflow but I don't get it to work.

Which API key do I have to use?

Here are the various APIs listed: https://apiportal.ns.nl/products

I used the key of https://apiportal.ns.nl/products/NsApp but when I try the Alfred search, I get following error message: Can't parse server response. 

Am I using the key of the right NS product?

Thanks

 

Screenshot 2023-01-04 at 11.58.28.png

Hi KorteAnton!

 

This is the correct product you're using. Can you please tell me more about how you use the API key? 

I've just tried to create a test account and use the newly generated API key and it seemed to work with no issues.

Link to comment
On 12/28/2022 at 8:59 PM, vitor said:

Wouldn’t it make sense to instead use a comma to separate station names always? As in: ns amsterdam, rotterdam and ns den haag centraal, utrecht leidsche rijn. Maybe names with spaces are rare enough that the underscore makes more sense, just pointing it out in case it wasn’t considered.

good point, thanks.

I'll think about how to best implement this.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...