NYC subway math

1 · Erik Bernhardsson · April 4, 2016, 4 a.m.
Apparently MTA (the company running the NYC subway) has a real-time API. My fascination for the subway takes autistic proportions and so obviously I had to analyze some of the data. The documentation is somewhat terrible, but here’s some relevant code for how to use the API: from google.transit import gtfs_realtime_pb2 import urllib for feed_id in [1, 2, 11]: feed = gtfs_realtime_pb2.FeedMessage() response = urllib.urlopen('http://datamine.mta.info/mta_esi.php?key=%s&feed_id=%d' % (os.e...