Why add links to the response of a REST API?
08:49 14 Aug 2018

Why do developers add links to the response of a REST API? For example, at paginated response in this tutorial.

{
    "_links": {
        "self": {
            "href": "http://example.org/api/user?page=3"
        },
        "first": {
            "href": "http://example.org/api/user"
        },
        "prev": {
            "href": "http://example.org/api/user?page=2"
        },
        "next": {
            "href": "http://example.org/api/user?page=4"
        },
        "last": {
            "href": "http://example.org/api/user?page=133"
        }
    }
    "count": 3,
    "total": 498,
    "_embedded": {
        ...
    }
}

It's pretty much easy to generate such link at the frontend.

rest