create the REST API and fix bugs