title: Should a RESTful API return data which is reshaped for the UI
body: <p>Lets assume ONE team uses the API to return data to a SPA in the browser.</p>
  
  <p>Is it RESTful to return data which is specially prepared for the UI of the SPA?</p>
  
  <p>Instead the client could prepare the data specially with JS what many want to avoid.</p>
  
  <p>WHAT means reshaped? =></p>
  
  <pre><code>public async Task&lt;IEnumerable&lt;SchoolclassCodeDTO&gt;&gt; GetSchoolclassCodesAsync(int schoolyearId)
  {
      var schoolclassCodes = await schoolclassCodeRepository.GetSchoolclassCodesAsync(schoolyearId);
      var allPupils = schoolclassCodes.SelectMany(s =&gt; s.Pupils).Distinct&lt;Pupil&gt;(new PupilDistinctComparer());
  
      var allPupilsDTOs = allPupils.Select(p =&gt; p.ToPupilDTO());
      var schoolclassCodeDTOs = schoolclassCodes.Select(s =&gt; s.ToSchoolclassDTO());
  
      // Prepare data specially for UI DataGrid with checkboxes
      foreach (var s in schoolclassCodeDTOs)
      {
          foreach (var p in allPupilsDTOs)
          {
              var targetPupil = s.Pupils.SingleOrDefault(pupil =&gt; pupil.Id == p.Id);
              if(targetPupil == null)
              {
                  p.IsSelected = false;
                  s.Pupils.Add(p);
              }
              else
              {
                  targetPupil.IsSelected = true;
              }
          }
      }
      return schoolclassCodeDTOs;
  }
  </code></pre>