If the endpoint returns json, then there is no other way than base64 how to embed binaries in the response. But this is definitely a bad idea due to performance issues. Maybe for some icons this will be fine, but for large images this is not suitable.
So, the best solution here is to return the URL to the image. And the client will request raw bytes for the image.
It is also worth mentioning that the image url can be not only the path to the static file, but also the path to some webapi endpoint, which, for example, receives bytes of the image using the resource identifier and sends the client binary back, and not the json string.
source share