Resolving problems in api.py