[REST] Post-Merge overhaul of the REST API

Can you use the correct style here?
``if (formats.length() > 0) {`` and so on.