There is no license information available for the latest version (1.0.0) of this package.

Communicates with the NS api

1.0.0 2017-11-22 19:18 UTC

This package is not auto-updated.

Last update: 2022-05-14 04:51:11 UTC


Laravel ns-api wrapper


In your project root, type:

$ composer require wubs/ns-api

After it is installed, add 'Wubs\NS\NSServiceProvider', to app/config.php in the providers array and add 'NS' => 'Wubs\NS\Facades\NS', to the aliases array, also in app/config.php.

Laravel usage

Train Stations

Receive a collection of all the train stations:

$stations = NS::stations();

This returns a Collection of Station objects a Station object has the following properties:

$station = $stations->first();


To receive a list of planned and unplanned failures:

$failures = NS::failures(ut'); //full name or code from a station
$planned = $failures->planned; //Collection of planned failures
$unplanned = $failures->unplanned; //Collection of unplanned failures

A Failure object has the following properties:

$failure->date; //Carbon date object

Travel Advise

A travel advise exists of multiple objects. One Advise Object has one ore more Notification objects in a Collection alo, it has muliple Step objects. Each Step object has multiple WayPoint objects in a Collection WayPoints are the train stations that are part of your travel advise, but you don't stop there. The first and the last items in this Collection are the start and end station for that part of the travel advise.

$advises = NS::advise('Aalten', "Zurich"); //Returns a Collection with Advise objects
$advise = $advises->first();
$advise->notifications; //Collection|Notification[]
$advise->plannedDepartureTime; //Carbon
$advise->actualDepartureTime; //Carbon
$advise->plannedArrivalTime; //Carbon
$advise->actualArrivalTime; //Carbon
$advise->steps; //Collection|Steps[]

$notification = $advise->notifications->first();

$step = $advise->steps->first();
$step->wayPoints; //Collection|WayPoint[]

$wayPoint = $step->wayPoints->first();
$wayPoint->time; //Carbon