Now using AbstractJSONable.
Fix formatting errors in api.py

Stop `python3 api.py` falling over around the API#listener and API#query
methods.
Merges pheudx's formatting fix and fixed raise exeption in api.py
Merge branch 'phuedx-formattingError'