Package: mobilitylabs-bsdprof
Python wrapper for the mobilitylabs APIThis repo contains a Python library with some classes to easily access themobilitylabs APIwhich allows the access to theBusEMTMad,BiciMAD GoandParkingEMTMadservices among others. These services are part of theMobilityLabs Madridopen and interoperable platform.In addition to the Python wrappersome test applications are included; this will help to let you know how everything works and, on top of that, you can use it to interact with the service once you get your own credencials and store them in thecredentials.inifile.The following are the requirements needed to make it work:Python 3(3.7.3+)AXClientIDandpasskeyin order to use the services; you can get your own XClientID and passkey by following the steps outlined inCreate an application in the EMTing portal, which is reduced down to:Creating your owndeveloper accountCreating anEMTing ApplicationThis Python library has been successfully tested withOSBDET S21R1on a Debian 10 x64 host.Remember to add the library to thePYTHONPATH environment variableif you want to use it from your code or if you want to run the tests Python scripts; you can do so by running the following line within the folder where the repo was cloned:$ export PYTHONPATH=$PYTHONPATH:`pwd`If you want to persist this environment variable,add it to your user's profileand it'll be created everytime you log into your computer.BusEMTMadTheBusEMTMadclass allows you to leverage information about buses in the great city of Madrid, which is provided by the EMT (Empresa Municipal de Transportes); this class wrapps theBlock 3 TRANSPORT BUSEMTMADsection in the official documentation, although not all the functions/webmethods are wrapped.The following are the functions/webmethods wrapped at the moment:info_lines(date_ref) -It returns the list of active bus lines in the reference date.info_line(line_id, date_ref) -It returns detailed info of a specific bus line in the reference date.info_stops() -It returns the list of active bus stops and information about them.info_stop(stop_id) -It returns detailed info of a specific bus stop.line_stops(line_id,direction) -It returns the list of bus stops of a bus line keeping in mind the direction (1 - start to end, 2 - end to start)issues(line_id) -It returns details about incidents or issues identified and impacting bus lines.buses_arrivals(stop_id, line_id="") -It returns the real time estimation of how far the buses are from the stop and how much time will take them to get to the bus stop. Only buses from the line specified will be considered (lineId is optional).test_busemtmad.pylet you test this service easily; before you can use it, get your own XClientID and passkey and store them into thecredentials.inifile.test_busemtmad.py -hwill give you all the details on how to run it:$ tests/test_busemtmad.py -h
usage: test_busemtmad.py [-h] [-lid LINEID] [-sid STOPID] [-dir {1,2}]
                         {info_lines,info_line,info_stops,info_stop,line_stops,issues,buses_arrivals} credentials_file

positional arguments:
  {info_lines,info_line,info_stops,info_stop,line_stops,issues,buses_arrivals}
                        what is going to be requested to the BusEMTMad service
  credentials_file       path to the file with info to access the service

optional arguments:
  -h, --help            show this help message and exit
  -lid LINEID, --line_id LINEID
                        bus line identifier for actions 'info_line', 'line_stops' and 'issues'; this argument is optional
                        for action 'buses_arrivals'
  -sid STOPID, --stop_id STOPID
                        stop identifier for action 'info_stop' and 'buses_arrivals'
  -dir {1,2}, --direction {1,2}
                        direction to be considered to analyze line info for action 'line_stops'; 1 for start to end, 2
                        for end to startBiciMAD GoTheBiciMadclass allows you to leverage information about bikes and bike stations in the great city of Madrid, which is provided by the BiciMAD GO service; this class wrapps theBlock 4 TRANSPORT BICIMADsection in the official documentation, although not all the functions/webmethods are wrapped.The following are the functions/webmethods wrapped at the moment:info_bike_stations() -It returns the details of Madrid BiciMad Stations.info_bike_station(bike_station_id) -It returns the details of a specific Madrid BiciMad Station.info_bikes() -It returns the details of Madrid BiciMad bikes.info_bike(bike_id): -It returns the details of a specific bike from the Madrid BiciMad service.test_bicimad.pylet you test this service easily; before you can use it, get your own XClientID and passkey and store them into thecredentials.inifile.test_bicimad.py -hwill give you all the details on how to run it:$ tests/test_bicimad.py -h
usage: test_bicimad.py [-h] [-sid BIKESTATIONID] [-bid BIKEID]
                       {info_bike_stations,info_bike_station,info_bikes,info_bike} credentials_file

positional arguments:
  {info_bike_stations,info_bike_station,info_bikes,info_bike}
                        what is going to be requested to the BiciMAD GO service
  credentialsFile       path to the file with info to access the service

optional arguments:
  -h, --help            show this help message and exit
  -sid BIKESTATIONID, --bike_station_id BIKESTATIONID
                        bike station identifier for action 'info_bike_station'
  -bid BIKEID, --bike_id BIKEID
                        bike identifier for action 'info_bike'ParkingEMTMadTheParkingEMTMadclass allows you to leverage information about parking areas in the great city of Madrid, which is provided by the EMT (Empresa Municipal de Transportes); this class wrapps theBlock 5 PARKINGSsection in the official documentation, although not all the functions/webmethods are wrapped.The following are the functions/webmethods wrapped at the moment:info_parkings() -It returns the list of active parking areas operated by the EMT.info_parking(parking_id) -It returns the details of a specific parking area.availability() -It returns availability for those parking areas publishing this information. Not all of them make this information public.test_parkings.pylet you test this service easily; before you can use it, get your own XClientID and passkey and store them into thecredentials.inifile.test_parkings.py -hwill give you all the details on how to run it:$ tests/test_parkings.py -h
usage: test_parkings.py [-h] [-id PARKINGID] {info_parkings,info_parking,availability} credentials_file

positional arguments:
  {info_parkings,info_parking,availability}
                        what is going to be requested to the ParkingEMTMad service
  credentialsFile       path to the file with info to access the service

optional arguments:
  -h, --help            show this help message and exit
  -id PARKINGID, --parking_id PARKINGID
                        parking area identifier for action 'info_parking'Changelogv0.1 (20210410) -initial release.