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.0

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.0
File Size Uploaded
txjsonrpc_ng-0.9.0.tar.gz 15.2 kB Details

Built distribution (wheel)

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

Total release size: 33.6 kB

Release files / txjsonrpc_ng-0.9.0.tar.gz

Download URL txjsonrpc_ng-0.9.0.tar.gz
Size 15.2 kB
Tags Source
SHA-256 checksum
How to use checksums
98ba091e544980b00ef17da41929d48502cb10e9e99caf1d551095285fc43a48
BLAKE2b-256 checksum
How to use checksums
b4e4fb00b26cc85a0ab83e0f117b840a4c545147e5666803bc0536ed8214897a
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.0-py3-none-any.whl

Download URL txjsonrpc_ng-0.9.0-py3-none-any.whl
Size 18.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
748f6208e5552300890e72d646a9f1e91dcce19d2debe602ad9706d183c0032b
BLAKE2b-256 checksum
How to use checksums
69d81456f8bd472dc3d53067fb31fb3f447034a2d99ec82f5c64842664dcf74d
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

0.9.2

2 release files

0.9.1

2 release files

This release

0.9.0 This release

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