Attempt to correctly escape identifiers.

NOTE: Due to a bug in the way go parses URLs, identifiers with a / are
not correctly escaped.  This is a wont-fix in this library, we'll wait
for the issue to be correct upstream.
Implementation of key/apis
Refactor out some repeated code