Skip to main content

txjsonrpc-ng

PyPI version Python versions License Quality gate Coverage Reliability rating OpenSSF Scorecard

Introduction

txjsonrpc-ng is an asynchronous JSON-RPC library for Python built on Twisted. It allows you to create async Python JSON-RPC servers and clients either over HTTP or directly on TCP with the Netstring protocol.

Features

  • 🚀 Asynchronous: Built on Twisted for high-performance async I/O

  • 🌐 Multiple Transports: HTTP and TCP (Netstring) support

  • 📋 Protocol Versions: Supports JSON-RPC pre-1.0, 1.0, and 2.0

  • 🔒 Authentication: Built-in authentication support

  • 🔍 Introspection: Built-in method introspection (listMethods, methodHelp, methodSignature)

  • 📚 jsonrpclib: Similar to Python’s xmlrpclib for easy migration

Installation

Install from PyPI using pip:

pip install txjsonrpc-ng

Or using Poetry:

poetry add txjsonrpc-ng

Requirements:

  • Python 3.10 or higher

  • Twisted 25.5 or higher

Quick Start

Server Example (HTTP)

from twisted.web import server
from twisted.internet import reactor
from txjsonrpc_ng.web.jsonrpc import Handler

class ExampleHandler(Handler):
    def jsonrpc_echo(self, message):
        """Echo the message back"""
        return message

    def jsonrpc_add(self, a, b):
        """Add two numbers"""
        return a + b

if __name__ == '__main__':
    r = ExampleHandler()
    reactor.listenTCP(8080, server.Site(r))
    print("JSON-RPC server running on http://localhost:8080/")
    reactor.run()

Client Example (HTTP)

from twisted.internet import reactor
from txjsonrpc_ng.web.jsonrpc import Proxy

def printResult(result):
    print("Result:", result)
    reactor.stop()

def printError(error):
    print("Error:", error)
    reactor.stop()

if __name__ == '__main__':
    proxy = Proxy('http://localhost:8080/')
    d = proxy.callRemote('add', 5, 3)
    d.addCallback(printResult)
    d.addErrback(printError)
    reactor.run()

Examples

More examples are available in the examples/ directory:

  • examples/web/ - HTTP-based JSON-RPC

  • examples/tcp/ - TCP/Netstring-based JSON-RPC

  • examples/ssl/ - SSL-secured JSON-RPC

  • examples/webAuth/ - Authenticated JSON-RPC

Documentation

  • Installation: See docs/INSTALL.md

  • Usage Guide: See docs/USAGE.md

  • Specifications: See docs/specs/ for JSON-RPC protocol versions

  • Contributing: See CONTRIBUTING.md

  • Security: See SECURITY.md

License

txjsonrpc-ng is licensed under the MIT License. See LICENSE for details.

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

Support

Metadata

Release files for txjsonrpc-ng 0.9.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for txjsonrpc-ng 0.9.2
File Size Uploaded
txjsonrpc_ng-0.9.2.tar.gz 15.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for txjsonrpc-ng 0.9.2
File Interpreter ABI Platform
txjsonrpc_ng-0.9.2-py3-none-any.whl Python 3 none any Details

Total release size: 35.0 kB

Release files / txjsonrpc_ng-0.9.2.tar.gz

Download URL txjsonrpc_ng-0.9.2.tar.gz
Size 15.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6446a145877050180a7de047a9aaa18769e67b56f81cb5ead6fa0a057824bf21
BLAKE2b-256 checksum
How to use checksums
8de0968a5c25e51c69db6fce29e4af84120db7b5a6d7e0ef1f4027d4fd7d79dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.3 CPython/3.14.7 Darwin/27.0.0

Release files / txjsonrpc_ng-0.9.2-py3-none-any.whl

Download URL txjsonrpc_ng-0.9.2-py3-none-any.whl
Size 19.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a4d5983d6ae170cb9fb87a2b65e95ef4c582dcbadcc46e56ebc14e5058c762ec
BLAKE2b-256 checksum
How to use checksums
96adaf7cb8e5f69d66a83e35a5679ac0aa1b88fccba5ec5515b83a54f1639899
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.3 CPython/3.14.7 Darwin/27.0.0

Release history Release notifications | RSS feed

This release

0.9.2 This release

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.4

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page