A basic JSON-RPC Implementation for Django powered sites (see


Simple, pythonic API Supports JSON-RPC 2.0 Spec

The basic API:


from pe.jsonrpc.views import JsonRpcView
from pe.jsonrpc.decorators import publicmethod

class TestRpcMethods(object):
    namespace = "test"
    def hello(self, who="World"):
        return "Hello, %s!" % who
    def echo(self, value):
        return value

rpc = JsonRpcView.as_view(classes=[TestRpcMethods])


from django.conf.urls.defaults import *

urlpatterns = patterns('', 
    (r'^rpc/json/$', 'app.views.rpc'),

To test your service: You can test the service with jsonrpclib ( or similar:

>>> from jsonrpclib import Server

>>> s = Server('http://localhost:8000/rpc/json/')

>>> s.test.hello()
u'Hello, World!'

>>> s.test.hello('Andrew')
u'Hello, Andrew!'

>>> s.test.hello(who='Bob')
u'Hello, Bob!'

>>> s.test.echo('This is a test...')
u'This is a test...'
Last modified 7 years ago Last modified on 03/21/2011 12:59:20 AM
Back to Top