def routes_list(): """Returns a list of all available routes in the sf-muni agency.""" params = utils.qs_params(command='routeList',data=request.args) resp=proxy_pass(params=params) jdata=xmltodict.parse(resp.content, dict_constructor=dict) stats.put_stats(response=resp, request=request) return jsonify(jdata)
def predictions_stopId(stopId): """Show prediction by route with stopId only - least specific""" params = utils.qs_params( command='predictions', data=request.args, stopId=stopId ) resp=proxy_pass(params=params) jdata=xmltodict.parse(resp.content, dict_constructor=dict) stats.put_stats(response=resp, request=request) return jsonify(jdata)
def routes_config(routeTag): """Returns details about a given routeTag.""" params = utils.qs_params( command='routeConfig', data=request.args, r=routeTag ) resp=proxy_pass(params=params) jdata=xmltodict.parse(resp.content, dict_constructor=dict) stats.put_stats(response=resp, request=request) return jsonify(jdata)
def vehicle_locations_route(routeTag): """Returns currently acitve vehicles for specified routeTag.""" params = utils.qs_params( command='vehicleLocations', data=request.args, r=routeTag ) resp=proxy_pass(params=params) jdata=xmltodict.parse(resp.content, dict_constructor=dict) stats.put_stats(response=resp, request=request) return jsonify(jdata)
def routes_schedule(routeTag): """Return predictions for """ params = utils.qs_params( command='schedule', data=request.args, r=routeTag ) resp=proxy_pass(params=params) jdata=xmltodict.parse(resp.content, dict_constructor=dict) stats.put_stats(response=resp, request=request) return jsonify(jdata)
def predictions_stopTag_and_route(routeTag,stopTag): """Show prediction by routes with routeTag and stopId - most specific""" params = utils.qs_params( command='predictions', data=request.args, r=routeTag, s=stopTag ) resp=proxy_pass(params=params) jdata=xmltodict.parse(resp.content, dict_constructor=dict) stats.put_stats(response=resp, request=request) return jsonify(jdata)
def routes_off_hours(timewindow): """Returns all routes that are not running during the specified time frame. Under construnction :( """ params = utils.qs_params( command='vehicleLocations', data=request.args, r=routeTag ) resp=proxy_pass(params=params) jdata=xmltodict.parse(resp.content, dict_constructor=dict) stats.put_stats(response=resp, request=request) return jsonify(jdata)
def routes_messages(): """Returns currently active messages and notifications for routes specified by parameter 'r'. If you want to specify multiple routes, use the 'r[]' key in the query string. If no routes are specified, all active messages will be returned.""" params = utils.qs_params( command='messages', data=request.args ) resp=proxy_pass(params=params) jdata=xmltodict.parse(resp.content, dict_constructor=dict) stats.put_stats(response=resp, request=request) return jsonify(jdata)
def predictions_for_multi_stops(): """Show time predictions for multiple stops specified by an array of stop/route tags. Use the 'r' parameter suffixed with empty brackets as the key (r[]), and seperate route tags from stop tags with a vertical pipe delimited with commas (routeTag|stopTag).""" params = utils.qs_params( command='predictionForMultiStops', data=request.args ) resp=proxy_pass(params=params) jdata=xmltodict.parse(resp.content, dict_constructor=dict) stats.put_stats(response=resp, request=request) return jsonify(jdata)