てきとうなメモ

本の感想とか技術メモとか

REST APIとHypertext

Roy FieldingがSocialSite REST API(OpenSocial APIの拡張)に対して,これはRestfulではなくRPCだと指摘している.何でもかんでもRESTfulと呼ぶんじゃないと.

I am getting frustrated by the number of people calling any HTTP-based interface a REST API. Today’s example is the SocialSite REST API. That is RPC.

Blogging Roller: The X-rated SocialSite API

で,SocialSite REST APIを作ったDave Johnsonが,これはOpenSocial REST APIOpenSocial JSON-RPC APIを両方とも拡張しているので,JSON-RPCの部分はRESTfulじゃないんですと弁解している

Project SocialSite is simply implementing and extending the OpenSocial API. OpenSocial includes both a JSON-RPC API and a REST API. SocialSite implements and extends them both. I never meant to imply that the JSON-RPC API is RESTful (and neither did the authors of the OpenSocial specifications).

Blogging Roller: The X-rated SocialSite API

でも,元の文章を読むと,根はもっと深いところにあるっぽい.そもそもOpenSocial REST API自体RESTfulではないと.

Roy T. Fielding says:
October 20th, 2008 at 9:22 am
The OpenSocial RESTful protocol is not RESTful. It could be made so with some relatively small changes, but right now it is just wrapping RPC results in common Web media types.

少し読んだ感じだと,どこにどのリソースがあるかという情報はサーバが提供しクライアントが選択すべきであって,クライアントが前もって知らなくてはならないのは良くないというのが一番大きいところなのかなと思う.

ただ,以下のようなmedia typeの処理方法についての記述を書いているAPIのドキュメントってほとんどみたことないなあ.

A REST API should spend almost all of its descriptive effort in defining the media type(s) used for representing resources and driving application state, or in defining extended relation names and/or hypertext-enabled mark-up for existing standard media types. Any effort spent describing what methods to use on what URIs of interest should be entirely defined within the scope of the processing rules for a media type

コメント欄まで読むとちょっとだけ理解できたような.