A tiny NodeJS wrapper for the National Rail SOAP api, requiring only node-soap.
The National Rail SOAP api is pretty nasty to get your head around for someone used to a RESTful architecture. This wrapper aims to simplify the experience using callbacks and json.
This fork makes the following changes to the orginal:
- Updates the Darwin version to the most recent; and
- Returns all results from Darwin, and not just the
trainServices
object.
Go to http://realtime.nationalrail.co.uk/OpenLDBWSRegistration/
and register for an api key.
After that, install this package.
npm i uk-trains
Within your NodeJS app, load the package, supply your api key, and then use the returned service.
var ukTrains = require('uk-trains');
var rail = ukTrains('xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx')
rail.getDepartures('MYB', undefined, console.log);
Get Departures from a specific station. Optionally you can request where the services depart to, how many services to request, and whether to include specific details about each train.
fromStation (String) the three letter station code you are requesting departures from
options (Object) optional or undefined
toStation: (String) the three letter station code you are requesting departures to
count: 20 (Number) the maximum number of services to request
includeServiceDetails: (Boolean) the api can also return information about each service (train) This is usually a long request, so only use it when you need it
callback (Function) Function to call with the result upon completion of the request
Get arrivals at a specific station. Optionally you can request where the services are arriving from, how many services to request, and whether to include specific details about each train.
atStation (String) the three letter station code you are requesting arrivals at
options (Object) optional or undefined
fromStation: (String) the three letter station code you are requesting departures to
count: 20 (Number) the maximum number of services to request
includeServiceDetails: (Boolean) the api can also return information about each service (train) This is usually a long request, so only use it when you need it
callback (Function) Function to call with the result upon completion of the request
Get all services relating to a station. Optionally you can request how many services to request, and whether to include specific details about each train.
station (String) the three letter station code you are requesting services at
options (Object) optional or undefined
count: 20 (Number) the maximum number of services to request
includeServiceDetails: (Boolean) the api can also return information about each service (train) This is usually a long request, so only use it when you need it
callback (Function) Function to call with the result upon completion of the request
Get specific details about an individual service (train).
serviceID (String) the service code you are requesting details regarding
callback (Function) Function to call with the result upon completion of the request