Restful api

Make the API restful. #292 should be merged before this. See #282 for more details.

Fixes #282.
Fixes #274 inherently.