Closed Lignum closed 4 years ago
Hmm, I feel like this is adding effort that should really be done on the consumer's end. JSON is pretty standard and easy to use, and IMO we should instead be removing the old API and requiring people to use the new one. Otherwise, we'll end up having three separate APIs, two of which are documented.
I agree; I feel we need to be focusing on deprecating the old API, and maintaining all of them would be a lot of hassle.
prs welcome
As there is still a significant amount of people using the deprecated API, it seems necessary to aid with adoption of the current API. Some people actively use the deprecated interface because they do not like the fact that they have to parse JSON, because they feel that the inclusion of a library bloats their program, or because they simply do not know how.
Thus, I propose that we add an option to the API to return data in plaintext. This should be done by setting the
Accept
header in the request totext/plain
, which should make the request contain only the most significant property of the requested object, if possible. For instance/work
should respond with the work,/addresses/:address
should respond with the balance of the address. Naturally, this behaviour would have to be documented. In some cases, such as responses returning lists of objects (like/transactions
or/addresses
), a plaintext format would be unreasonable. In such cases, the API should respond with an empty body and the status code415 Unsupported Media Type
.