skip to navigation
skip to content

json-rpc 1.10.3

JSON-RPC transport realisation

JSON-RPC2.0 and JSON-RPC1.0 transport specification implementation. Supports python2.6+, python3.3+, PyPy. Has optional Django and Flask support. 200+ tests.


This implementation does not have any transport functionality realization, only protocol. Any client or server realization is easy based on current code, but requires transport libraries, such as requests, gevent or zmq, see examples.


pip install json-rpc




  • Vanilla python, no dependencies
  • Optional backend support for Django, Flask
  • json-rpc 1.1 and 2.0 support


Server (uses Werkzeug)

from werkzeug.wrappers import Request, Response
from werkzeug.serving import run_simple

from jsonrpc import JSONRPCResponseManager, dispatcher

def foobar(**kwargs):
    return kwargs["foo"] + kwargs["bar"]

def application(request):
    # Dispatcher is dictionary {<method_name>: callable}
    dispatcher["echo"] = lambda s: s
    dispatcher["add"] = lambda a, b: a + b

    response = JSONRPCResponseManager.handle(, dispatcher)
    return Response(response.json, mimetype='application/json')

if __name__ == '__main__':
    run_simple('localhost', 4000, application)

Client (uses requests)

import requests
import json

def main():
    url = "http://localhost:4000/jsonrpc"
    headers = {'content-type': 'application/json'}

    # Example echo method
    payload = {
        "method": "echo",
        "params": ["echome!"],
        "jsonrpc": "2.0",
        "id": 0,
    response =
        url, data=json.dumps(payload), headers=headers).json()

    assert response["result"] == "echome!"
    assert response["jsonrpc"]
    assert response["id"] == 0

if __name__ == "__main__":


There are several libraries implementing JSON-RPC protocol. List below represents python libraries, none of the supports python3. tinyrpc looks better than others.


json-rpc is a python library, it supports pythons: 2.6, 2.7, 3.3, 3.4. There is optional support for django1.6 (python2.6 does not support django1.7).


File Type Py Version Uploaded on Size
json-rpc-1.10.3.tar.gz (md5) Source 2016-02-02 26KB
json_rpc-1.10.3-py2.py3-none-any.whl (md5) Python Wheel 2.7 2016-02-02 37KB