3.1 JSON-RPC Methods
The value of the "method" field in an OpenSocial JSON-RPC request uses a format of "<service-name>.<operation>". <service-name> is a string [A-Za-z0-9_]+ that identifies one of the services listed in [Services] and <operation> is a string [A-Za-z0-9_]+ that identifies an operation supported by that service.
All OpenSocial services MUST expose a "get" [TBD query, fetch are valid alternatives] operation.
Operations with the names get, create, update and delete should map to
the HTTP equivalent operations in the RESTful API of GET, PUT, POST
& DELETE
3.2 Services
The names of the JSON-RPC services MUST match the names used in the OpenSocial namespace E.g http://ns.opensocial.org/messages/0.8
Containers MAY give access to the JSON-RPC services using a URL addressing scheme to invoke a single RPC via HTTP GET. It is recommended that only services that are idempotent are exported in this manner. Containers MUST use the following canonical transformation between the JSON-RPC structure and its URL encoding
Operation | Parameters |
Return |
get | AuthToken auth = HttpRequest.Authorization, String userid = "@me", String groupid = "@self", Array.<String> fields, int count, int startIndex, int startPage | opensocial.Person or Array.<opensocial.Person> |
create | AuthToken auth = HttpRequest.Authorization, String userid = "@me", String groupid = "@friends", opensocial.Person person | opensocial.Person |
update | AuthToken auth = HttpRequest.Authorization, String userid = "@me", String groupid = "@self", opensocial.Person person | opensocial.Person |
delete | AuthToken auth = HttpRequest.Authorization, String userid = "@me", String groupid = "@self" | Void |
8.1.1 get
Retrieve a single person or list of opensocial.Person objects. Supports returning a limited set of fields on returned Person objects and control of the order and paging in a returned list.
8.1.2 create
Support creating opensocial.Activity objects as the targets of a relationship with the specified user, this is a generalization of many use cases including invitation, contact creation etc. Implementation of this method is not required to be OpenSocial compliant
8.1.3 udpate
Support updating the properties of an opensocial.Person object identified by its relationship to the specified user. Implementation of this method is not required to be OpenSocial compliant
8.1.4 delete
Support removing the relationship between an opensocial.Person and the specified user. Implementation of this method is not required to be OpenSocial compliant
Operation | Parameters | Return |
get | AuthToken auth = HttpRequest.Authorization, String userid = "@me", String groupid = "@self", Array.<String> fields, int count, int startIndex, int startPage | opensocoal.Activity or Array.<opensocial.Activity> |
create | AuthToken auth = HttpRequest.Authorization, String userid = "@me", String groupid = "@self", opensocial.Activity activity | opensocial.Activity |
update | AuthToken auth = HttpRequest.Authorization, String userid =
"@me", String groupid = "@self", opensocial.Activity activity |
opensocial.Activity |
delete | AuthToken auth = HttpRequest.Authorization, String userid = "@me", String groupid = "@self", String activityId | Void |
8.2.1 get
Retrieve a one or list of opensocial.Activity objects. Supports returning a limited set of fields on returned Activity objects and control of the order and paging in a returned list.
8.2.2 create
Support creating
opensocial.Activity objects as the targets of a relationship with the
specified user, the specifically
supported use case is posting a new activity to the stream of a single
user i.e activity.create(userid="@me",groupid="@self", <some
activity>) Support for other parameterizations is not required to be
OpenSocial compliant.
8.2.3 udpate
Support updating opensocial.Activity objects as the targets of a relationship with the specified user. Implementation of this method is not required to be OpenSocial compliant
8.2.4 delete
Support removing the relationship between an opensocial.Activity and the specified user. Implementation of this method is not required to be OpenSocial compliant
Operation | Parameters | Return |
get | AuthToken auth = HttpRequest.Authorization, String userid = "@me", String
groupid = "@self", String appId = auth.AppId, Array.<String> keys | Map.<String, String> |
update | AuthToken auth = HttpRequest.Authorization, String userid =
"@me", String groupid = "@self", String appId = auth.AppId, Map.<String, String> data | Void |
delete | AuthToken auth = HttpRequest.Authorization, String userid = "@me", String groupid = "@self", String appId = auth.AppId, Array.<String> keys | Map.<String, String> |
8.3.1 get
Retrieve a map of key-value pairs for the list of specified keys.
8.3.2 udpate
Add or replace key-value pairs stored in a users appdata with the key-vaues in the data parameter.
8.3.3 delete
Operation |
Parameters | Return |
send | AuthToken auth = HttpRequest.Authorization, String userid = "@me", opensocial.Message message | Void |
8.3.1 send
Send an opensocial.Message object to its defined recipients.
Operation | Parameters | Return |
listMethods | Array.<String> | |
methodSignatures | String methodName |
Signature |
methodHelp |
String methodName | Content |
8.5.1 listMethods
Containers
MUST imlpement this operation which takes no parameters and returns an
array of all methods supported by the endpoint including the system
methods. For a container which only supports read access to people
& read and create access for activities the result would be
["people.get", "activities.get", "activities.create", "system.listMethods", "system.methodSignatures", "system.methodHelp"]
8.5.2 methodSignatures
Containers
MUST implement this operation that returns a method signature
describing the types of the parameters, their default values and the
type of the return value for a given operation. Note that this scheme
does not match that used for XML-RPC definition of method signatures
which only specifies a mapping for positional parameters. Type
definitions used here match the scheme used in the OpenSocial
Javascript API. The example below is the Signature response for
people.get
{
"return" : ["opensocial.Person", "Array.<opensocial.Person>"],
"auth" : {
"default" : null,
"type" : "AuthToken"
},
"userid" : {
"default" : "@me",
"type" : "String"
},
"groupid" : {
"default" : "@self",
"type" : "String"
},
"fields" : {
"default" : ["id","name","thumbnailUrl","profileUrl"],
"type" : "Array.<String>"
},
"count" : {
"type" : "int",
"required" : false
},
"startIndex" : {
"type" : "int",
"required" : false
}
"startPage" : {
"type" : "int",
"required" : false
}
}
The "return" field indicates the type of the result. If the service can return more than one type then the value is an array of the possible return types. Each named field in the response maps to a parameter of the operation and contains information about the types and values accepted for that parameter. The existence of "default" in the parameter detail indicates the parameter has a default value. The value of a default may be null which means that its not introspectable and usually means that it is some complex derivation. Parameters are assumed to be required unless otherwise indicated by the existence of the "required" field with a value of false.
8.5.3 methodHelp
Containers MAY implement this operation that returns a textual description of the operation identified by the methodName parameter. A container can choose to return either plaintext or HTML as the response.
Code | Meaning |
-32700 (Parse error) | Invalid JSON. An error occurred on the server while parsing the JSON text. |
-32600 (Invalid Request) |
The received JSON not a valid JSON-RPC or batch of JSON-RPCs |
-32601 (Method not found) | The requested remote-procedure does not exist / is not available. |
-32602 (Invalid params) | Invalid method parameters. |
-32603 (Internal server error) | Internal server error |
-32099..-32000 | Reserved for implementation-defined server-errors. |
401 (Unauthorized) | Access token does not grant access to the resource |
404 (Not Found) | The requested resource was not found |
409 (Conflict) |
The requested update conflicts with a prior change |
0-1000 | Reserved for future use by this specification |
> The genesis for the proposal is that the existing RESTful proposal
> is difficult to consume for developers that are primarily focused on
> JSON. This proposal reduces the need for the different encoding
> strategies required to generate and parse RESTful requests. In
> particular the RESTful API requires parsing of URLs, Atom or JSON &
> Multi-part for batch. The proposal tries to use JSON as the one
> syntax for representing the full structure of individual and batch
> requests.
Could you elaborate further? If there is such complexity, may the
RESTful API need fixing.
Subbu
I think the assumption of this spec is that there are some problems
with the complexity of the current RESTful proposal, but that it is
easier to add, then to take away from a spec that's already published.
> I think there are a number of issues:
>
> 1. To interpret the contents of a RESTful JSON batch response a
> client must parse HTTP multi-part, then parse URLs and then parse
> JSON This is a VERY BIG burden on app developers and IMHO a barrier
> to adoption. To create a batch request they must be able to
> construct these forms. Any protocol which requires 3 parsing steps
> to understand the semantics of a message incurs a cost in
> transparency.
I did bring this up with John several months ago. But the assumption,
I was told, was that the this complexity will be hidden underneath
some JS APIs. If that is not the case, the batch proposal needs to be
re re-evaluated. Batching is a pipe-dream and be best solved by
creating compound/aggregate resources, as Roy Fielding recently
commented
"Just define a resource that maps to all of the resources you intend
to operate upon. Resources often overlap."
If batch is the only painful aspect, then I don't think it justifies
an RPC-over-HTTP API (which is intrinsically bad).
Subbu
I did bring this up with John several months ago. But the assumption,
On Jul 18, 2008, at 12:49 PM, Louis Ryan wrote:
> I think there are a number of issues:
>
> 1. To interpret the contents of a RESTful JSON batch response a
> client must parse HTTP multi-part, then parse URLs and then parse
> JSON This is a VERY BIG burden on app developers and IMHO a barrier
> to adoption. To create a batch request they must be able to
> construct these forms. Any protocol which requires 3 parsing steps
> to understand the semantics of a message incurs a cost in
> transparency.
I was told, was that the this complexity will be hidden underneath
some JS APIs. If that is not the case, the batch proposal needs to be
re re-evaluated. Batching is a pipe-dream and be best solved by
creating compound/aggregate resources, as Roy Fielding recently
commented
"Just define a resource that maps to all of the resources you intend
to operate upon. Resources often overlap."
If batch is the only painful aspect, then I don't think it justifies
an RPC-over-HTTP API (which is intrinsically bad).
Subbu
> This is an argument that will have to be made concretely in the
> context of OpenSocial to be consumable. Attempts to create
I agree, and that would reduce the complexity with the generic batch
mechanism as proposed.
Subbu
I agree with John on this. Batching shouldn’t be THE argument for RPC. For some reason, I cannot envision Open Social with RPC. Again, in the name of popular demand, I can also be persuaded ;o)
Cheers
<k/>
P.S : Am in Portland this week OSCON/XMPP summit. Didn’t see an OpenSocial presentation.
From:
opensocial-an...@googlegroups.com
[mailto:opensocial-an...@googlegroups.com] On Behalf Of John
Panzer
Sent: Sunday, July 20, 2008 2:47 PM
To: opensocial-an...@googlegroups.com
Subject: Re: PROPOSAL - A JSON-RPC API for OpenSocial.
I would really like to get feedback from implementers (particularly gadget servers that would use the REST API, and gadget authors who would like to use the REST API from JS) to see what they think on this topic.
John,
If the alternative you're referring to in 3. is the one currently used for the JS in Shindig I'll happily post it, if its something else I REALLY think you need to post some examples just so folks know what theyre voting for when/if we get around to that.
I do have a couple of questions about this proposal. Small things.
Section 2.1 - Should the json-rpc version be included explicitly in
the request so as to future-proof it?
Section 2.2 - In the example response, it says:
{
"myself" : {
"id":"myself",
"result" : {
...
}
},
"myfriends" : {
"id" : "myfriends",
"result" : {
...
}
}
}
It seems like marking each entry with a separate container keyed by
the request id is redundant. Why not just have a collection of tuples,
where the first field in each tuple is the id, that contains the
request id field passed in the request?
Section 7 - Question 1 - Is the use of URL addressing optional for the
single request, i.e., could it also use the batch style?
Comment on subrequests - In the case where a subrequest defines its
own OAuth, the whole subsigning process seems a bit cumbersome. Not
sure if there is a better way.
Otherwise, it looks good.
Bob
2008/7/17 Louis Ryan <lr...@google.com>:
> createAuthToken auth = HttpRequest.Authorization, String userid = "@me",
> startPageopensocoal.Activity or Array.<opensocial.Activity>
> keysMap.<String, String>
>
> 8.3.1 get
>
> Retrieve a map of key-value pairs for the list of specified keys.
>
> 8.3.2 udpate
>
> Add or replace key-value pairs stored in a users appdata with the key-vaues
> in the data parameter.
>
> 8.3.3 delete
>
> Remove the specifed keys from a users appdata and returned the values
> associated with those removed keys.
>
> 8.4 Messaging
>
> service-name = "messages"
>
> Operations summary:
> Operation
> Parameters
> Return
> sendAuthToken auth = HttpRequest.Authorization, String userid = "@me",
> -32601 (Method not found)The requested remote-procedure does not exist / is
I am not sure if this is the right thread to +1 the JSON-RPC proposal,
but +1, and please direct me to the right thread otherwise.
I do have a couple of questions about this proposal. Small things.
Section 2.1 - Should the json-rpc version be included explicitly in
the request so as to future-proof it?
Section 2.2 - In the example response, it says:
{
"myself" : {
"id":"myself",
"result" : {
...
}
},
"myfriends" : {
"id" : "myfriends",
"result" : {
...
}
}
}
It seems like marking each entry with a separate container keyed by
the request id is redundant. Why not just have a collection of tuples,
where the first field in each tuple is the id, that contains the
request id field passed in the request?
Section 7 - Question 1 - Is the use of URL addressing optional for the
single request, i.e., could it also use the batch style?
Comment on subrequests - In the case where a subrequest defines its
own OAuth, the whole subsigning process seems a bit cumbersome. Not
sure if there is a better way.
Good point, I think having an initial request send of the opensocial
version from the client would be a great idea.
>
>
>>
>>
>> Section 2.2 - In the example response, it says:
>> {
>> "myself" : {
>> "id":"myself",
>> "result" : {
>> ...
>> }
>> },
>> "myfriends" : {
>> "id" : "myfriends",
>> "result" : {
>> ...
>> }
>> }
>> }
>>
>> It seems like marking each entry with a separate container keyed by
>> the request id is redundant. Why not just have a collection of tuples,
>> where the first field in each tuple is the id, that contains the
>> request id field passed in the request?
>
> This could certainly be converted into an array instead of an associative
> array without much difficult, however a collection of tuples seems less
> useful when consuming. E.g.
>
> [ {id:x, response:{}}, ...] is reasonable I think but you dont get to use
> the required unique id to access the value in the array. In the associative
> variant you can do response.<id>.result.
>
Another good point, I guess you could get rid of the nested property
for id, but then that would be more work to deserialize properly. OK,
seems fine :-)