Richard Bailey Richard Bailey - 1 month ago 6x
reST (reStructuredText) Question

Loading many base64 images from RESTful API

Background Information:

I have a person table which among others holds the image of the person. The image is encoded in base64 (limited to 128 x 128). So through the API you can make a call that will return all the person data. There could be 10 records or 1000 records (paging is an option). For each base64 string within the response the size is more or less 40k bytes. So if your loading, let's say 100 records, the packet size if quite large, taking into account that there are additional data that's returned for each person record.


Would it be considered best practice to return the base64 encoded images in the json response, or should one rather make use of a URL link?

Apologies if this is a re-post, but I did review the Similar Questions section, but couldn't find anything that answered my question.

Many thanks in advance!


It is better to handle the image of the person as a separate resource and give it "its own" URL. In the JSON data of a person this URL is embedded as an property, like

   id: "personId",
   imageUri: "http://..../profile.jpg"


  • The JSON for query results on person data is much more compact
  • The Binary Image data can be transmitted without the Base64 overhead

  • The browser can cache the image


  • To fetch the complete person data two requests are necessary. One for the person's metadata and one for the image.