I'm developing an API for returning either a single product or a collection of products, so will have endpoints like http://api.company.com/products/ and http://api.company.com/products/1/ that return data in the following structures:
// http://api.company.com/products/1/
{
Id: 1
Name: "Product 1"
}
// http://api.company.com/products/
[
{
Id: 1,
Name: "Product 1"
},
{
Id: 2,
Name: "Product 2"
}
]
I'm currently using the following media types in the Accept header, respectively:
application/vnd.company.product-v1.0+json // single product
application/vnd.company.products-v1.0+json // collection of products
Now it doesn't seem ideal to have two media types with "product"
and "products"
as I can see that leading to some confusion, but they do return different structures of data. So I'm wondering if there's any kind of API standard here that dictates whether you should only use one media type for both or not?