Return metadata in API results.

Currently the API results are largely dummy values or very simple JSON representations of the returned objects. We probably need to return metadata and such too.

Part of this responsibility will likely fall to the collection implementations so we'll need to modify the interface between request handlers and the collections somewhat.

Part of #4.