Roy lays out six rules that designers of REST APIs should follow and
in the comments (see comment #5) says "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."
I must admit, it is not clear to me how OpenSocial REST API violates
the six rules that Roy stated. The API does change any communications
protocol, the spec does seem mostly concerned with defining resources,
resource names are not dictated and instead discovered via XRDS and
there is one bookmarkable entry point (the XRDS file). In my last
comment on Roy's blog asked him to spell out those "relatively small
changes".
- Dave
That's what I thought (and hoped) too, but I already pointed out that
distinction and as you can see in his comment, he links directly to
the RESTful protocol spec.
- Dave
That's what I thought (and hoped) too, but I already pointed out that
On Mon, Oct 20, 2008 at 5:31 PM, John Panzer <jpa...@google.com> wrote:
> The OpenSocial JSON-RPC API isn't RESTful, but it doesn't claim to be
> either. Perhaps there is some confusion since originally the OpenSocial
> Protocol was known as the OpenSocial RESTful Protocol. The JSON-RPC part
> was added in the spring, and of course doesn't fit under the RESTful
> umbrella. I suspect that's what he's looking at.
distinction and as you can see in his comment, he links directly to
the RESTful protocol spec.
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.
A truly RESTful API looks like hypertext. Every addressable unit of information carries an address, either explicitly (e.g., link and id attributes) or implicitly (e.g., derived from the media type definition and representation structure). Query results are represented by a list of links with summary information, not by arrays of object representations (query is not a substitute for identification of resources). Resource representations are self-descriptive: the client does not need to know if a resource is OpenSocialist because it is just acting on the representations received.
Think of it in terms of the Web. How many Web browsers are aware of the distinction between an online-banking resource and a Wiki resource? None of them. They don't need to be aware of the resource types. What they need to be aware of is the potential state transitions — the links and forms — and what semantics/actions are implied by traversing those links. A browser represents them as distinct UI controls so that a user can see potential transitions and anticipate the effect of chosen actions. A spider can follow them to the extent that the relationships are known to be safe. Typed relations, specific media types, and action-specific elements provide the guidance needed for automated agents.
I have not looked at the latest API that is being developed on this
list, but you may still want to consider using a opensocial-specific
media type for XML as well. The Atom wrapper does not really
compensate for using a generic application/xml media type for
atom:content.
> Since application/json doesn't define namespaces or other standard
> ways to further define its type, we could use application/opensocial
> +json instead (define our own media type and suggest a pattern for
> others to do the same based on JSON). This would enable those
> generic tools he talks about to deal with the content by
> interpreting it properly, regardless of how it found the resource(s).
Even using an "application/opensocial+json" media type across the
board is not better than application/json. The key litmus test is to
check if a server or a client can guess what is contained in a request
or response just by looking at the media type. Different kinds of
opensocial resources deserve their own media types.
Sincerely,
Subbu
---
http://subbu.org
The structure of the response object returned from a successful request for the JSON or XML formats is as follows. The root element isresponse, which is shown explicitly as the root element in XML format, and is the anonymous root object returned when the format is json (i.e. in JSON, the response returned is the object value of the response node). The response node MUST contain the following child nodes, and MAY contain additional nodes that the Service Provider wishes to add to expose additional data. Note thatstartIndex, itemsPerPage, and totalResults are based on OpenSearch."
John—
Do you have a suggested patch to the spec? We might not be able to get this into 0.9, but getting it in within the next couple iterations would be great.
-Scott