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 12 years ago Last modified on 03/21/11 05:59:20
Back to Top