4

I just spent a whole day reading the Fielding's famous dissertation on REST. It says at the Conclusion part that :

REST, a novel architectural style for distributed hypermedia systems. ...

Although Web-based applications can include access to other styles of interaction, the central focus of its protocol and performance concerns is distributed hypermedia. REST elaborates only those portions of the architecture that are considered essential for Internet-scale distributed hypermedia interaction.

And according to Wikipedia:

Hypermedia, an extension of the term hypertext, is a nonlinear medium of information which includes graphics, audio, video, plain text and hyperlinks.

So it appears to me REST is kind of meant for web-based content-intensive system. But obviously RESTful API has been a buzzword used in almost everywhere regarding web service.

So is this kind of over-use? Or mis-use?

Refs:

RESTful APIs, the big lie.

What exactly is RESTful programming?

What does "hypermedia data formats" mean in Fielding's famous dissertation when talking about Cookies

Community
  • 1
  • 1
smwikipedia
  • 61,609
  • 92
  • 309
  • 482

1 Answers1

5

I think JSON is not more or less media than text or video are. So in essence, a serialized object represented in JSON is a medium.

Now "hypermedia" is media that is linked together semantically. You can make JSON hypermedia by including links: HAL, or HATEAOS.

Herein you add links to related resources to a JSON document. Example:

{
    "content": [ {
        "price": 499.00,
        "description": "Apple tablet device",
        "name": "iPad",
        "links": [ {
            "rel": "self",
            "href": "http://localhost:8080/product/1"
        } ],
        "attributes": {
            "connector": "socket"
        }
    }, {
        "price": 49.00,
        "description": "Dock for iPhone/iPad",
        "name": "Dock",
        "links": [ {
            "rel": "self",
            "href": "http://localhost:8080/product/3"
        } ],
        "attributes": {
            "connector": "plug"
        }
    } ],
    "links": [ {
        "rel": "product.search",
        "href": "http://localhost:8080/product/search"
    } ]
}   

People argue that without links, JSON is not hypermedia.

I'm also a big fan of not trying to cram every API into REST. Not every API is about resources, so if your API represents RPC instead, call it what it is: an RPC API.

CodeCaster
  • 147,647
  • 23
  • 218
  • 272
  • I always had the same line of thinking. I don't get why people make serious excuses to call their API's REST. It seems they are afraid to say so! Weird! – jpgrassi Dec 19 '15 at 16:44