Content type of links

#1

Are there any recommended strategies for specifying the content type of links? E.g. suppose that in addition to the JSON representation of the resource pointed to by links.self, there are HTML and PDF versions of the resource.

In general you’d want your JSON, HTML and PDF to all reside at the same location (self link), and for the requested Content-Type to be discriminating factor, but

  • a) how do you document that the alternative formats are available if you only include a single self, and
  • b) what if the other representations don’t actually reside at the same address?
{
  ...
  "id": 1,
  "links": {
    "self": "https://api.com/resources/1",
    "pdf": "https://api.com/resources/obfuscated-pdf-url",
    ...
  }
}

^ Is all I can think of.

0 Likes