switching to api from routes