Skip to main content

Python3 asyncio JSONRPC module

Project description

``aiojsonrpc2`` is a Python3 JSONRPC module built using ``asyncio``.

  • Supports Python 3.5+ only (uses async/await syntax)
  • Plain socket transport (not JSONRPC over HTTP)
  • Supports secure TLS (ie. SSL) sockets

This is a new, fast, and modern JSONRPC module originally built to support `aiostratum_proxy <>`__ (a next-gen, extensible cryptocurrency mining proxy). However, releasing it as it’s own independent Python package made the most sense.


There are currently no external dependencies required for aiojsonrpc2, and installation is simple:

pip install aiojsonrpc2


To use aiojsonrpc2 and depending on your needs, you need to implement either a client or server ‘protocol’. Both ClientProtocol and ServerProtocol let you handle bi-directional JSONRPC communication.

All incoming JSONRPC requests infer a protocol instance method from the JSONRPC method parameter. For example, if the method contains client.show_message, then the protocol class implementation must have an instance method called handle_client_show_message:

from aiojsonrpc2 import ClientProtocol, ServerProtocol

class MyClientProtocol(ClientProtocol):
    # NOTE: the opposing connection (perhaps a server) would
    # have sent the `client.show_message` request;
    # bidirectional communication!
    def handle_client_show_message(self, connection, params, **kwargs):
        # assuming the message to show is `params[0]`

Note how all . (ie. full stops/periods) from the JSONRPC method parameter are replaced by _ (ie. underscore).

Future Considerations

Community involvement is appreciated. Code review, pull requests for bug fixes & improvements, reporting issues, spreading the word - all appreciated.


Project details

Download files

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

Files for aiojsonrpc2, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size aiojsonrpc2-1.0.0-py3-none-any.whl (9.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size aiojsonrpc2-1.0.0.tar.gz (8.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page