Make api able to marshal its types correctly

This frees everyone from having to think about the "Kind" field: use api.Encode and api.Decode[Into] instead of json|yaml.Marshal/Unmarshal.

To make it easy on tests, I'm also making the rule that the Kind field is *not* set in go objects. Since we already know what type they are, it's not needed.

I also switched some types that we were passing as string but converting to []byte everywhere. More efficient to pass as []byte, anyway.
I added "data, err" to the return line. I can go all the way with this particular function and remove the named output parameters if you like (this function is long enough that I'm ambivilent). I don't think we should outlaw them in general though.