moved api called from views.py to api.py