流行的版本设计策略

I am currently working on a REST API, and the question was raised, how are, and how should, REST APIs be versioned? Here are the results of my research.

It seems that there are a number of people recommending using Content-Negotiation (the HTTP “Accept:” header) for API versioning. However, none of the big public REST APIs I have looked at seem to be using this approach. They almost exclusively put the API version number in the URI, with the odd exception using a custom HTTP header. I am at somewhat of a loss to explain this disconnect.

Versioning strategies in discussions

POSTVERSIONING
Stack Overflow 1URI
Stack Overflow 2Content Negotiation
blog post by JeremyContent Negotiation
ycombinator discussionsome opinions both ways
Stack Overflow 3Content Negotiation
Stack Overflow 4Content Negotiation
notmessenger blog postURI (against all headers)
Peter WilliamsContent Negotiation (strongly against URIs) 
Apigee Blog post on API versioningURI (some discussion)
Mark Nottingham REST versioningRecommending essentially versionless extensibility with a HATEOS approach
Nick Berardi on REST versioningURI
Restify“Accept-Version” header
Tom Maguire on REST versioningContent Negotiation
Nicholas Zakas on Rest VersioningURI
Steve Klabnik on Rest VersioningContent Negotiation + HATEOS
Luis Rei on Rest VersioningContent Negotiation with (;version=1.0)
kohana forum discussion on REST versioningMany Opinions
Troy Hunt on REST versioningAccept Header but also support custom header and URL
Paul Gear REST versioningRecommending essentially versionless extensibility with a HATEOS approach

Versioning strategies in popular REST APIs

API NAMEVERSIONINGEXAMPLE
Twillodate in URI 
TwitterURI 
AtlassianURI 
Google SearchURI 
Github APIURI/Media Type in v3 Intention is to remove versioning in favour of hypermedia – current application/vnd.github.v3
AzureCustom Headerx-ms-version: 2011-08-18
FacebookURI/optional versioninggraph.facebook.com/v1.0/me
Bing MapsURI 
Google mapsunknown/strange 
NetflixURI parameterhttp://api.netflix.com/catalog/titles/series/70023522?v=1.5
SalesforceURI with version introspection{
“label”:”Winter ’10”
“version”:”20.0″,
“url”:”/services/data/v20.0″,
}
Google data API (youtube/spreadsheets/others)URI parameter or custom header“GData-Version: X.0” or “v=X.0”
FlickrNo versioning? 
DiggURIhttp://services.digg.com/2.0/comment.bury
DeliciousURIhttps://api.del.icio.us/v1/posts/update
Last FMURIhttp://ws.audioscrobbler.com/2.0/
LinkedInURIhttp://api.linkedin.com/v1/people/~/connections
FoursquareURIhttps://api.foursquare.com/v2/venues/40a55d80f964a52020f31ee3?oauth_token=XXX&v=YYYYMMDD
FreebaseURIhttps://www.googleapis.com/freebase/v1/search?query=nirvana&indent=true
paypalparameter&VERSION=XX.0
TwitpicURIhttp://api.twitpic.com/2/upload.format
EtsyURIhttp://openapi.etsy.com/v2
TropoURIhttps://api.tropo.com/1.0/sessions
TumblrURIapi.tumblr.com/v2/user/
openstreetmapURI and response bodyhttp://server/api/0.6/changeset/create
EbayURI (I think)http://open.api.ebay.com/shopping?version=713
RedditNo versioning? 
GrouponURIhttp://api.groupon.com/v2/channels//deals{.json|.xml}
Geonames  
Wikipediano versioning I think? 
BitlyURIhttps://api-ssl.bitly.com/v3/shorten
DisqusURIhttps://disqus.com/api/3.0/posts/remove.json
YammerURI/api/v1
Drop BoxURIhttps://api.dropbox.com/1/oauth/request_token
Amazon Simple Queue Service (Soap)URI Parameter and WSDL URI&Version=2011-10-01
Youtube data API versioningURIhttps://www.googleapis.com/youtube/v3

Versioning strategies in popular REST Libraries

LIBRARY NAMEVERSIONINGEXAMPLE
node-restify semver versioning in an accept-Version headeraccept-version: ~3
Jerseydescription of how to do Accept: header versioning in JerseyAccept: application/vnd.musicstore-v1+json

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值