- Github
- Facebook Graph API
- Stripe
- Strava
- RunKepper
- Feedly
- Mashery
- Foursquare
- RottenTomatoes
- Twilio
- Sales Force Desk
4 main options:
- URL
- Accept Header
- Custom Header
- Query String
Mark Nottingham - Chair of the Hypertext Transfer Protocol Bis Working Group HTTPbis WG. Mark has many thoughts on the subject, some of them listed below:
Proponents of URLs
Proponents of Accept Header:
Haters of Custom Header:
No particular opinion:
Organisation | Versioning Method |
---|---|
GitHub | Accept |
URL | |
URL | |
Stripe | URL & Custom |
URL | |
Runkeeper | Accept |
Feedly | URL |
Foursquare | URL & Query String |
RottenTomatoes | URL |
Strava | URL |
Lexical Scope's view of the world here.
Some considerations:
- Can a JS client send the accept header in all browsers? Test this JSFiddle
- Will proxies and other places where caching takes place cause problems if the headers are used to version?
Accept Header:
- [+] Widely accepted this is a sound use case for the header
- [-] Need to send back Vary header with Accept listed in order to ensure caches work
Custom Header:
- [-] Potential conflict with other header
- [-] Less support than using a standard Accept Header / not seen to be the way to do it
URL:
- [+] Is a good way to version big changes
- [+] It is really easy to see what version is being requested
- [+] It is the most common, widely used mechanism
- [+] A web browser can be used to change version being requested
- [+] No worries about clients not being able to handle setting headers or caches becoming stale because they ignore headers
Closing thoughts:
It breaks down to 2 types of changes:
- Changes to the representation of the stuff (new properties added, old ones taken away).
- Changes to the resources of the stuff (new methods, options like query string params).
Using the URL to do versioning is an additional pressure on what URLs are already used to do. i.e. identify resources, provide links to other resource, be cache keys.
Overall...
- Think about the future
- Do not, unless absolutely neccessary, break stuff
- Make everything backwards compatible
- Aim to get things as correct as possible, from the earliest possible point
- Think about what is being versioned - is it the resource or the representation?
Additional information: