4 ms·
The version thing is interesting. How do you maintain various current versions of an API? If a URI cannot contain a version number (as the purists would claim)
by pan69 13y ago
The version thing is interesting. How do you maintain various current versions of an API? If a URI cannot contain a version number (as the purists would claim) then versioning happens in the underlying code base? If so, a client still would have to specify a version, either in a query parameters, request header or somewhere else.
In reality, if an API doesn't contain a version number in it's URI will almost be impossible to maintain. To give a simple example, what if you decide to switch technologies between API v1 and v2? How would you deal with that? Some sort of abstraction layer I'd guess...
As far as I'm concerned, a version number in the URI makes the most sense. They way I look at is is that /v1/resources/123 is a different resource than /v2/resources/123.
So far, using a version number in the URI has worked out quite well for me over time since I can isolate various code bases containing different versions. Something that would not have been possible otherwise.
- dllthomas 13y agoMy understanding is that request header is the most standards compliant way. In principle, you could certainly determine how you interpret the URL based on that. In practice, both clients and servers aren't really designed for that, though. Particularly browsers, if you expect people to want to access/explore your API that way.
- dragonwriter 13y ago> If a URI cannot contain a version number (as the purists would claim) then versioning happens in the underlying code base? It happens in the underlying code base whether or not it is reflected in the URI; one "pure" REST would have it in the Content-Type, but that's problematic with pure-HTML forms.
- pbreit 13y agoDon't version. You'd be surprised how easy and powerful such a thing is.