News for hackers. Stuff that matters.
Re:APIs Are Forever, Wait No...They Can Go Away at Any Time by kijin on Saturday April 21, 2012 @12:52PM (#3872219)
That looks like a too rigid view of what REST requires.

It's possible to view different versions of an API as different representations of the same data. For example, an HTTP server is permitted to return different responses, or even return an error, depending on the contents of the client's "Accept:" header. If versioning was done with a header instead of the URL, it would achieve essentially the same results. The client would be saying "I want /user/123/posts/recent, and I want it in the APIv3 format."

If an API method changes so much that it is no longer recognizable as a different representation of the same data, the URL should probably change to reflect the new content. The old URL would then return data only when the old version is requested, and "406 Not Acceptable" when the new version is requested. So I don't see any reason why API versioning can't be RESTful. It's just slightly more difficult to do it RESTfully, compared to adding the version in the URL.

In any case, I'd rather take practicality over RESTful purity.

There are no comments on this comment yet.