Returning Multiple Types in same response


#1

We have use case where we need to return multiple types in one response (for example below). Is this allowed? Can we return multiple types in one response?

{
data: [{
type: “company”,
id: “123”,
attributes: {
name: “foo”,
image: “foo.jpg”,
sex: “male”
}
}, {
type: “person”,
id: “1232”,
attributes: {
title: “freebie”,
image: “freebie.jpg”,
offer: “Free manicure”,
promo-code: “free-mani-2015”,
}
}]
}


#2

Yes, there is no limitations about this case in the spec.

But do you really need it?


#3

Thanks. Yes, we have use case where customer can search multiple types of resources in one API. Those resources have very few fields in common and most of the fields are different.