Social Coding

How does a client know what to do when encountering a link-type inside a rel-tag?

Using links is the most important part of HATEOAS. With links, clients can discover the possibilities and actions that can take place in your API. However, clients should know what a specific link does. This can be found through the relation-type, which is stored in the "rel"-attributes.

<link rel="comments" type="application/x.atom+xml" title="Blog comments" href="http://.."/>

There are specific relation types that are predefined. If you use one of these relation-types inside your own API, you MUST make sure they behave as expected, otherwise this might confuse your clients. See below for a link to these relation-types.

If you use non-standard relation types, they are required to be URIs. You can help clients understand what your custom link relation types do by making the URI de-referenceable, and place the documentation for that relation at that URI.

See also


Get in Touch