Improve: refactoring sample api.php