Creating a new function for API request