I am currently working on an API that tries to do a little bit of HATEOAS by including links to related resources in API responses.
In some places, I have (ab?)used the links for things like article images. So, for example a article resource might look like this:
{
"type": "article",
"id": "1",
"links": {
"self": "/api/articles/1",
"image": "/files/b4d7802c-9cbb-4b65-9181-28cb547d2796"
},
"attributes": {
"title": "My first blog entry",
"slug": "first",
"created_at": "2016-08-01T00:00:00Z"
}
}
As you can see, I've added the link to the article's image to the links
hash. The thinking was: It's an URL, so it should probably go there. However, one could just as well argue that the article image is an attribute of the article.
So, my question: Are there any agreed-upon guidelines in the REST community that deal with how to judge whether a URL is a hypermedia link or an attribute? What are the benefits / disadvantages of either approach?