Onionoo doesn't return JSON for error responses
From the Onionoo docs:
Onionoo clients send HTTP GET requests to the Onionoo server which responds with JSON-formatted replies.
Clients should be able to handle all valid JSON responses
However Onionoo only returns JSON on a successful response, errors are returned in HMTL. For example:
Returns JSON: https://onionoo.torproject.org/summary?limit=1
Returns HTML: https://onionoo.torproject.org/summary?limit=foo
The HTTP lib I'm using in my Onionoo client library is configured for JSON so it automatically parses the response for me. This means when I get an error (400 Bad Request in the above example) I don't get a chance to throw a useful bad request request error as the HTTP lib has already thrown a parse error.
I've implemented a fix by configuring my HTTP lib for text responses and then manually parsing the JSON myself, only for successful responses. This obviously isn't a major issue but I think it would be better (and match the spec) if Onionoo returned errors formatted as JSON. If that's going to be an issue it should mention that errors are returned as HTML in the spec.