Search code examples
rest

REST services: why should I bother with supporting multiple resource representations?


I'm trying to wrap my head around REST principles, and the multiple representations principle confuses me. It'd appear to me that server side could be greatly simplified by having a single canonical representation of any given resource. Why should I add multiple format support?

"But different clients will have different needs!" Yes, and? Isn't it client's job to interpret the data they receive from the server? Some wacky client might prefer receiving a uu-encoded tar file, but should I add that ahead of time, too?

Basically, it appears to me so:

a) if server-side developer can influence client-side development (both sides are developed together), they should settle on a single canonical representation and use it.

b) if server-side developer can not influence client-side development (say, they are making a public API), they should implement a single canonical representation and let the clients adapt to it.

Obviously, I'm getting something wrong here, but what?


Solution

  • Your point b is not realistic for a widely used api with clients being added to existing apps in many different technologies. If you want lots of takeup then make it easier for clients.