clean up api.py