Write most of the higher-level REST API.

Doesn't completely compile yet, but the harder part is done.