Nondeterministic Programming Methodology
Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

node-trafikinfo

0.0.9 • Public • Published

Node Trafikinfo

Utility for connecting to the Swedish transit api in node. Takes any options specified here and a callback.
Module is incomplete and untested please don't use

Setup

npm install node-trafikinfo
var trafikClient = require('node-trafikinfo'),
    trafikinfo = new trafikClient('yourapikey');

Query departing train times

trafikinfo.get(
    {
        objectType: 'TrainAnnouncement',
        orderBy: 'ScheduledDepartureDateTime',
        filter: [
            { ActivityType: 'Avgang' },
            { LocationSignature: queryObj.from },
            { ToLocation: queryObj.to },
            { AdvertisedTimeAtLocation: ['-00:15:00','14:00:00'] }
        ],
        includes: [
            'AdvertisedTrainIdent',
            'ScheduledDepartureDateTime',
            'ToLocation'
        ]
    },
    function(data) {
        console.log(data)
    }
)

An example of querying all Train Station results:

trafikinfo.get(
    {
        objectType: 'TrainStation',
        includes: [
            'Prognosticated',
            'AdvertisedLocationName',
            'LocationSignature'
        ],
    },
    function(data) {
        console.log(data)
    }
)

An example of querying railway messages at a location:

trafikinfo.get(
    {
        objectType: 'TrainMessage',
        orderBy: 'AdvertisedTimeAtLocation',
        filter: [
            { AffectedLocation:'Cst' }
        ],
        includes: [
            'StartDateTime',
            'LastUpdateDateTime',
            'ExternalDescription',
            'ReasonCodeText'
        ]
    },
    function(data) {
        console.log(data)
    }
)

An example of querying a train's timetable:

trafikinfo.get(
    {
        objectType: 'TrainAnnouncement',
        filter: [
            { AdvertisedTrainIdent: '535' }
        ],
    },
    function(data) {
        console.log(data)
    }
)

Install

npm i node-trafikinfo

DownloadsWeekly Downloads

2

Version

0.0.9

License

MIT

Last publish

Collaborators

  • avatar