abstract api calls behind function