Update api.py

Fix for python 3