Is it acceptable to only include relationship data on certain endpoints?

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.

I think it is valid not to provide the data in a relationships unless a related resource would appear in a compound document, whatever you decide to include the “tracks” by default or the client request its inclusion.

Compound documents require “full linkage”, meaning that every included resource MUST be identified by at least one resource identifier in the same document.