add api server and put main into class