Differences between revisions 1 and 2
Revision 1 as of 2012-03-12 11:17:48
Size: 1703
Editor: IanRees
Comment:
Revision 2 as of 2012-03-12 11:18:06
Size: 1704
Editor: IanRees
Comment:
Deletions are marked like this. Additions are marked like this.
Line 9: Line 9:
We have published a reference implementation of JSON-RPC for Python and Javascript. The Python module can be installed using the link above, or via "easy_install jsonrpc. We have published a reference implementation of JSON-RPC for Python and Javascript. The Python module can be installed using the link above, or via "easy_install jsonrpc".

Accessing the EMEN2 Public API using JSON-RPC and XML-RPC

All public API methods are available via both JSON-RPC and XML-RPC, which are language-neutral Remote Procedure Call protocols. Of these, JSON-RPC is recommended because it supports keyword arguments and has better representation of EMEN2 objects. We have published a simple JSON-RPC module for Python and Javascript (described below) that can be used with EMEN2. XML-RPC is also supported, and many programming environments include an xmlrpc library by default (as is the case with Python.)

JSON-RPC

We have published a reference implementation of JSON-RPC for Python and Javascript. The Python module can be installed using the link above, or via "easy_install jsonrpc".

Example:

>>> import jsonrpc.proxy
>>> import getpass
>>> db = jsonrpc.proxy.JSONRPCProxy("http://ncmidb.bcm.edu")
>>> ctxid = db.login("example@example.com", getpass.getpass())
Password: 
>>> db.getrecord(0, ctxid=ctxid)
{u'modifyuser': u'root', u'name': 0, u'creator': u'root', u'keytype': u'record', u'creationtime': u'2007-07-23T15:30:22+00:00', u'uri': None, u'comments': [], u'rectype': u'folder', u'history': [[u'root', u'2010-04-27T19:28:05+00:00', u'recname', u'EMEN2'], [u'root', u'2010-04-27T19:28:05+00:00', u'name_folder', None]], u'parents': [], u'groups': [u'authenticated'], u'modifytime': u'2010-04-27T19:28:05+00:00', u'name_folder': u'EMEN2', u'children': [268323, 449989, 268295, 136, 433788, 268330, 448491, 492525, 265550, 268336, 358307, 265561, 265514, 270940, 260317, 266174], u'permissions': [[], [], [], []]}

XML-RPC

...

EMEN2/rpc (last edited 2013-04-18 06:19:00 by IanRees)