Skip to main content

JSON-RPC transport implementation

Project description

Build Status Coverage Status Latest PyPI version Supported Python versions Gitter Bakers Sponsors

JSON-RPC2.0 and JSON-RPC1.0 transport specification implementation. Supports Python 2.6+, Python 3.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 implementation is easy based on current code, but requires transport libraries, such as requests, gevent or zmq, see examples.

  • Vanilla Python, no dependencies.
  • 200+ tests for multiple edge cases.
  • Optional backend support for Django, Flask.
  • json-rpc 1.1 and 2.0 support.


pip install json-rpc



This is an essential part of the library as there are a lot of edge cases in JSON-RPC standard. To manage a variety of supported python versions as well as optional backends json-rpc uses tox:



During local development use your python version with tox runner. For example, if your are using Python 3.6 run tox -e py36. It is easier to develop functionality for specific version first and then expands it to all of the supported versions.

Continuous integration

This project uses CircleCI for continuous integration. All of the python supported versions are managed via tox.ini and .circleci/config.yml files. Master branch test status is displayed on the badge in the beginning of this document.

Test matrix

json-rpc supports multiple python versions: 2.6+, 3.3+, pypy. This introduces difficulties with testing libraries and optional dependencies management. For example, python before version 3.3 does not support mock and there is a limited support for unittest2. Every dependency translates into if-then blocks in the source code and adds complexity to it. Hence, while cross-python support is a core feature of this library, cross-Django or cross-Flask support is limited. In general, json-rpc uses latest stable release which supports current python version. For example, python 2.6 is compatible with Django 1.6 and not compatible with any future versions.

Below is a testing matrix:

Python mock unittest Django Flask
2.6 2.0.0 unittest2 1.6 0.12.2
2.7 2.0.0   1.11 0.12.2
3.3     1.11 0.12.2
3.4     1.11 0.12.2
3.5     1.11 0.12.2
3.6     1.11 0.12.2
pypy 2.0.0   1.11 0.12.2
pypy3     1.11 0.12.2


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"

    # Example echo method
    payload = {
        "method": "echo",
        "params": ["echome!"],
        "jsonrpc": "2.0",
        "id": 0,
    response =, json=payload).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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

json-rpc-1.13.0.tar.gz (31.1 kB view hashes)

Uploaded source

Built Distribution

json_rpc-1.13.0-py2.py3-none-any.whl (41.3 kB view hashes)

Uploaded 3 6

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page