refactoring api_client initialization