16
What is the better design practice?
If I have object A and it contains some related objects for example I have a car object and it's various types.
Should I on request api.example.org/cars/1 respond just with ID's to those resources (so if someone need details about them another API call is required at api.example.org/type/1)
{
"id": 1,
"name": "Some Car",
"types": [
1,
2
]
}
or provide details about those resources as well
{
"id": 1,
"name": "Some Car",
"types": [
{
"id": 1,
"name": "Some Type",
"something": "Blah"
},
{
"id": 2,
"name": "Some Type",
"something": "Blah"
}
]
}
Or provide optional parameter like "displayAll" and then array with names of parameters which should be retrieved all in one API call (in this case types).