Created
August 2, 2017 13:44
-
-
Save viniciusCamargo/ade89f91305f838a2bc09e7fd8ec41f9 to your computer and use it in GitHub Desktop.
MTA GTFS Real Time Proto Decoder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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