api_request refactored