create Api class for frontend + little refactoring