Implements REST API of the main server.