Fix minor bug in api.py