Restful api

Make the API restful. See #282 for more details.

Fixes #282.