Return public API urls when appropriate.

When requested through the public API endpoint return a corresponding
public API id URL instead of the internal URL.