Move API client code into external library