pyemtmad.wrapper module

This file contains the API URL and endpoints for EMT.

See http://opendata.emtmadrid.es/Servicios-web

class pyemtmad.wrapper.Wrapper(emt_id='', emt_pass='')

Bases: object

Interface for the JSON API of the EMT services.

initialize(emt_id, emt_pass)

Manual initialization of the interface attributes.

This is useful when the interface must be declare but initialized later on with parsed configuration values.

Parameters:
  • emt_id (str) – ID given by the server upon registration
  • emt_pass (str) – Token given by the server upon registration
request_openbus(service, endpoint, **kwargs)

Make a request to the given endpoint of the openbus server.

This returns the plain JSON (dict) response which can then be parsed using one of the implemented types.

Parameters:
  • service (str) – Service to fetch (‘bus’ or ‘geo’).
  • endpoint (str) – Endpoint to send the request to. This string corresponds to the key in the ENDPOINTS dict.
  • **kwargs – Request arguments.
Returns:

Obtained response (dict) or None if the endpoint was not found.

request_parking(endpoint, url_args={}, **kwargs)

Make a request to the given endpoint of the parking server.

This returns the plain JSON (dict) response which can then be parsed using one of the implemented types.

Parameters:
  • endpoint (str) – Endpoint to send the request to. This string corresponds to the key in the ENDPOINTS dict.
  • url_args (dict) – Dictionary for URL string replacements.
  • **kwargs – Request arguments.
Returns:

Obtained response (dict) or None if the endpoint was not found.