Rutgers Buses

import requests

Fetching bus information from the passiogo API

url = 'https://passiogo.com/mapGetData.php?eta=3&deviceId=43137682&stopIds=21050&routeId=43440&position=3&userId=1268'
req = requests.get(url)
req.json()['ETAs']
{'21050': [{'bg': '#ffea3f',
   'OOS': 0,
   'eta': '8 min ',
   'etaR': '8',
   'busId': 4860,
   'color': '#000000',
   'dwell': None,
   'error': None,
   'order': 0,
   'speed': 6.778091981876064,
   'stopId': '21050',
   'tripId': 578788,
   'arrived': None,
   'busName': '4178',
   'created': '2024-04-08 17:06:35',
   'looping': '1',
   'routeId': '43440',
   'theStop': {'name': 'Hill Center (SB)',
    'busId': 4860,
    'stopId': '21050',
    'userId': '1268',
    'routeId': '43440',
    'position': 3,
    'routeName': 'H Route',
    'shortName': 'H',
    'routeStopId': '1156487'},
   'deviceId': 402695,
   'distance': 1,
   'outdated': 0,
   'busLatLng': [40.5040633, -74.4492506],
   'serviceTime': '',
   'stopsAmount': 2,
   'routeBlockId': '111635',
   'routeGroupId': None,
   'secondsSpent': 494,
   'scheduleTimes': [],
   'goShowSchedule': '0',
   'timezoneOffset': 0,
   'routeStopPosition': 7,
   'actualRouteBlockId': '111635',
   'busProjectionError': 3,
   'routePointPosition': 268,
   'busProjectionLatlng': {'lat': 40.504063806117486,
    'lng': -74.44921811175705},
   'stopRoutePointPosition': 66},
  {'bg': '#ffea3f',
   'OOS': 0,
   'eta': '12 min ',
   'etaR': '12',
   'busId': 4867,
   'color': '#000000',
   'dwell': None,
   'error': None,
   'order': 0,
   'speed': 10.11889546174798,
   'stopId': '21050',
   'tripId': 578774,
   'arrived': None,
   'busName': '4185',
   'created': '2024-04-08 17:06:40',
   'looping': '1',
   'routeId': '43440',
   'theStop': {'name': 'Hill Center (SB)',
    'busId': 4867,
    'stopId': '21050',
    'userId': '1268',
    'routeId': '43440',
    'position': 3,
    'routeName': 'H Route',
    'shortName': 'H',
    'routeStopId': '1156487'},
   'deviceId': 402725,
   'distance': 1,
   'outdated': 0,
   'busLatLng': [40.5039063, -74.448816],
   'serviceTime': '',
   'stopsAmount': 2,
   'routeBlockId': '111634',
   'routeGroupId': None,
   'secondsSpent': 697,
   'scheduleTimes': [],
   'goShowSchedule': '0',
   'timezoneOffset': 0,
   'routeStopPosition': 7,
   'actualRouteBlockId': '111634',
   'busProjectionError': 5,
   'routePointPosition': 266,
   'busProjectionLatlng': {'lat': 40.50387220795917,
    'lng': -74.44885148792204},
   'stopRoutePointPosition': 66},
  {'bg': '#ffea3f',
   'OOS': 0,
   'eta': '13 min ',
   'etaR': '13',
   'busId': 4839,
   'color': '#000000',
   'dwell': None,
   'error': None,
   'order': 0,
   'speed': 7.431231222689656,
   'stopId': '21050',
   'tripId': 578763,
   'arrived': None,
   'busName': '1002',
   'created': '2024-04-08 17:06:38',
   'looping': '1',
   'routeId': '43440',
   'theStop': {'name': 'Hill Center (SB)',
    'busId': 4839,
    'stopId': '21050',
    'userId': '1268',
    'routeId': '43440',
    'position': 3,
    'routeName': 'H Route',
    'shortName': 'H',
    'routeStopId': '1156487'},
   'deviceId': 411194,
   'distance': 1,
   'outdated': 0,
   'busLatLng': [40.516643, -74.4622946],
   'serviceTime': '',
   'stopsAmount': 2,
   'routeBlockId': '111633',
   'routeGroupId': None,
   'secondsSpent': 799,
   'scheduleTimes': [],
   'goShowSchedule': '0',
   'timezoneOffset': 0,
   'routeStopPosition': 3,
   'actualRouteBlockId': '111633',
   'busProjectionError': 4,
   'routePointPosition': 99,
   'busProjectionLatlng': {'lat': 40.516628731621395,
    'lng': -74.46225522430962},
   'stopRoutePointPosition': 66}]}
req.json()['ETAs']['21050'][0]['theStop']
{'name': 'Hill Center (SB)',
 'busId': 4860,
 'stopId': '21050',
 'userId': '1268',
 'routeId': '43440',
 'position': 3,
 'routeName': 'H Route',
 'shortName': 'H',
 'routeStopId': '1156487'}
for bus in req.json()['ETAs']['21050']:
    print(bus['busName'], bus['eta'], bus['theStop']['name'])
4178 8 min  Hill Center (SB)
4185 12 min  Hill Center (SB)
1002 13 min  Hill Center (SB)