api call as a function