completed api_adaptor.py