RESTful API (second try)

Implements the RESTful API and resolves #3 #5 and #16.