npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

irishrail-realtime-node

v1.1.2

Published

This is a Node.js Module for the IrishRail Real time service.

Downloads

9

Readme

irishrail-realtime-node

This is a Node.js Module for the IrishRail Real time service.

This Module works with ECMAScript 6.

This Module is based off the following websites:

  1. http://api.irishrail.ie/realtime/

  2. http://api.irishrail.ie/realtime/realtime.asmx

Installation

npm install irishrail-realtime-node

Usage

This needs to be included.

const  irishRailApi = require('irishrail-realtime-node');

How to use

Json Response

By default the irish rail Api returns all responses in XML. I have provided a way of converting the returned response to JSON instead of xml.

You can request a JSON response by setting the isJSONResponse parameter to either true or false.

Note: This default value for this parameter is false .

irishRailApi.getAllStations(); // returns all stations in XML format

OR

irishRailApi.getAllStations(true,params); // returns all stations filtered by params in JSON format

OR

irishRailApi.getAllStations(true); // returns all stations in JSON format

Parameters

The params argument is optional for getAllStations and getCurrentTrains and is not included at all in getHaconTrains.

In methods where the parameter is optional it can be called without it as shown below.

irishRailApi.getAllStations(true,params); // returns all stations filtered by params in JSON format

OR

irishRailApi.getAllStations(true); // returns all stations in JSON format

Exceptions

If there is an error calling the irish rail api the error will be thrown. You should catach these exceptions in by calling there functions in a try catch block. Example:

try {  
  let stations = await irishRailApi.getAllStations();  
  return res.status(200).send(stations);  
} catch (error) {  
  return res.status(400).json({status: 400, message: error});  
}

Promises

All the methods uses promises so you can use the await command when calling these methods. Example:

let trains = await irishRailApi.getCurrentTrains(true);

Get all Stations

This example returns a list of all stations in XML format

irishRailApi.getAllStations();

The below example returns a list of all stations in JSON format.

irishRailApi.getAllStations(true);

This example returns a list off all stations by type in JSON format.

Note: Possible values for the StationType parameter (A for All, M for Mainline, S for suburban and D for DART) any other value will be changed to A.

var  params = { StationType:'D'};

irishRailApi.getAllStations(true,params);

Get Current Trains

This example returns a list off all current trains in XML format.

irishRailApi.getCurrentTrains();

This example returns a list off all current trains in JSON format.

irishRailApi.getCurrentTrains(true);

This example returns a list off all DART stations in JSON format.

Note: Possible values for the TrainType parameter (A for All, M for Mainline, S for suburban and D for DART) any other value will be changed to A.

var  params = { TrainType:'D'};

irishRailApi.getCurrentTrains(true,params);

Get Station Data

The getStationData method must have 'StationDesc' or 'StationCode' as a parameter.

These bits of information can be gotten from the getAllStations api call.

An options parameter is 'NumMins' which returns all trains due to serve the named station in the next x minutes.

This example reutrns a stations current information.

var  params = { StationCode:'BFSTC', NumMins:'25'};

irishRailApi.getStationData(true,params);

Get Station Filter

The getStationsFilter method must have 'StationText' as a parameter.

This method returns a list of station names that contain the StationText.


var  params = { StationText:'br'};

irishRailApi.getStationsFilter(true,params);

Get Train Movements

The getTrainMovements method must have 'TrainId' and 'TrainDate' as a parameters.

The date for the 'TrainDate' parameter should be in dd/mm/yyyy format.

This method returns all stop information for the given train.

var  params = { TrainId:'123TR', TrainDate:  '19/03/2018'};

irishRailApi.getTrainMovements(true,params);

Get Hacon Trains

The getHaconTrains method doesn't take a params argument like all the previous methods.

This method returns all hacon trains.

irishRailApi.getHaconTrains(); // will return in XML

OR

irishRailApi.getHaconTrains(true); // will return in JSON