Move API request handling into API