

Ask HN: Versioning API URL vs. Header + MIME Type - edu

Hi,<p>I'm developing a RESTful API and one of the requirements is that it has to be versioned.<p>The usual solution is to add the version in the URI, http://example.com/api/v1/resource<p>But it doesn't feel completely right. The resource probably will be the same in another version just its representation or the parameters will change.<p>Then, I thought about using the Accept header with vendor specific MIME types to specify what API version to use. This way the resource will never change and it will be unique.<p>A simplified example of usage would be:
GET http://example.com/resource
Accept: application/vnd.example-api-v1.text+json<p>Update: formatting.
======
madhouse
You could even use something like "Accept: application/vnd.text+json;api-
version=1". Personally, I'd go with the custom Accept header, using the same
type, but different "accept-extension" (see
<http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html> for details).

~~~
edu
Good point, actualy Zend is doing it exactly like this:
[http://files.zend.com/help/Zend-Server-Community-
Edition/api...](http://files.zend.com/help/Zend-Server-Community-
Edition/api_versioning_negotation.htm)

