APIs and classes for transforming result grouping results into the appropriate response format