Skip to content

Instantly share code, notes, and snippets.

@viniciusCamargo
Created August 2, 2017 13:44
Show Gist options
  • Save viniciusCamargo/ade89f91305f838a2bc09e7fd8ec41f9 to your computer and use it in GitHub Desktop.
Save viniciusCamargo/ade89f91305f838a2bc09e7fd8ec41f9 to your computer and use it in GitHub Desktop.
MTA GTFS Real Time Proto Decoder
const Proto = require('protobufjs');
const Req = require('request');
var GtfsRealtimeBindings = require('gtfs-realtime-bindings');
const MTA_API_ENDPOINT = "http://datamine.mta.info/mta_esi.php?key=148133e77dd93f66b37d6c5054684401&feed_id=1"
Req({
method: 'GET',
url: MTA_API_ENDPOINT,
encoding: null
}, (err, response, body) => {
var feed = GtfsRealtimeBindings.FeedMessage.decode(body);
feed.entity.forEach(function(entity) {
if (entity.trip_update) {
console.log(entity.trip_update);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment