Fixed type errror on api.py