Pull out API calls into a connection object