Hi there.
I hope the topic is self-explanatory.
Basically, in my API I have two resource types: albums
and tracks
.
There are two endpoints, one for paginating all albums in the system (/albums
), and one for fetching a single album (/albums/$ALBUM_ID
).
This is an example response for paginating albums:
{
"data": [
"type": "albums",
"id": "1",
"attributes": {
"name": "Album 1"
},
"relationships": {
"tracks": {
"links": {
"related": "/albums/1/tracks"
}
}
}
]
}
And this is an example response for viewing a specific album:
{
"data": {
"type": "albums",
"id": "1",
"attributes": {
"name": "Album 1"
},
"relationships": {
"tracks": {
"data": [
{"type": "tracks", "id": 1},
{"type": "tracks", "id": 2},
{"type": "tracks", "id": 3}
],
"links": {
"related": "/albums/1/tracks"
}
}
}
}
Is this considered valid according to the spec? Specifically with regards to only including the actual relationship data when viewing a single album. When paginating albums, the relationship data is not included.