API endpoints refactor