Moved api calls from rest.py to api.py