finished api.py completely