I am posting this to see if there are any opinions out there on a best practice to handle redundancy in responses.
The data being returned in our REST API responses can become large depending on the specific call. This is partly because much of the data is repeated/redundant.
For example, the same items are repeated in different groups. See the XML below. When looking at the example ignore the meaning of a group, item etc., I just made up some element names for the purpose of the example.
An item can have a lot of information associated with it. It makes the most sense for us to represent the items at this level, however, we are trying to avoid having to the consumer make multiple calls to retrieve all the item information if we don't contain all the data at this level and we just provide the link/reference to the item. We want the response to contain all the data for each item but only want to represent it once in the response.
I'd be interested in hearing how others have addressed the redundancy issue while avoiding clients having to make multiple calls to your API. Sorry, if there is already a similar topic or question, I couldn't find one in this group. Thanks in advance!
Steve
<groups>
<group>
<itemCategory id="1001">
<code></code>
<description></description>
</itemCategory>
<items>
<item id="2001">
<code></code>
<description></description>
</item>
<item id="2002">
<code></code>
<description></description>
</item>
<item id="2003">
<code></code>
<description></description>
</item>
</items>
</group>
<group>
<itemCategory id="1002">
<code></code>
<description></description>
</itemCategory>
<items>
<item id="2001">
<code></code>
<description></description>
</item>
<item id="2002">
<code></code>
<description></description>
</item>
<item id="2003">
<code></code>
<description></description>
</item>
</items>
</group>
</groups>