node-trafikinfo
v0.0.9
Published
npm module for connecting to the swedish trafikinfo API
Downloads
2
Readme
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)
}
)