nodejs starter script for accessing RTD realtime feeds
GPL-3.0 License
nodejs module for accessing RTD realtime feeds. Data feed formatting follows GTFS-realtime specification.
Utilizes Google's GTFS-realtime binding library for NodeJS
npm install steveszc/rtd-realtime
var realtime = require('rtd-realtime');
realtime.VehiclePositions.load( (err,feed) => {
// 'err' will be supplied if an error occured in the request or decoding of the feed,
// otherwise 'err' will be null
// 'feed' will be supplied as decode json representation of a GTFS-RT feed
});
The VehiclePositions feed object will be made available to a callback
realtime.VehiclePositions.load( (err,feed) => {
// 'err' will be supplied if an error occured in the request or decoding of the feed,
// otherwise 'err' will be null
// 'feed' will be supplied as decode json representation of a GTFS-RT feed
});
VehiclePosition.json will be written to your file system The feed object will be made available to a callback
realtime.VehiclePositions.write( (err,feed) => {
// 'err' will be supplied if an error occured in the request or decoding of the feed,
// otherwise 'err' will be null
// 'feed' will be supplied as decode json representation of a GTFS-RT feed
// A JSON file of the feed will be written to your file system
});
The TripUpdates feed object will be made available to a callback
realtime.TripUpdates.load( (err,feed) => {
// 'err' will be supplied if an error occured in the request or decoding of the feed,
// otherwise 'err' will be null
// 'feed' will be supplied as decode json representation of a GTFS-RT feed
});
TripUpdates.json will be written to your file system The feed object will be made available to a callback
realtime.TripUpdates.load( (err,feed) => {
// 'feed' will be supplied as decode json representation of a GTFS-RT feed
// A JSON file of the feed will be written to your file system
});
This module includes a set of access credentials in config.js that are intended for development purposes only. Do not use these credentials in a production app. There is no guarantee that they will work. To request a unique set of credentials please visit the RTD Developer Resources webpage and request access to GTFS-RT. You'll need to fork this repo, update config.js with your credentials, and use that version in your app.