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

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.1
File Size Uploaded
txjsonrpc_ng-0.9.1.tar.gz 15.6 kB Details

Built distribution (wheel)

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

Total release size: 34.4 kB

Release files / txjsonrpc_ng-0.9.1.tar.gz

Download URL txjsonrpc_ng-0.9.1.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f94cd1bb93f2482867486765121c709b355f70ebf6d6837aa40f83cd1855acd9
BLAKE2b-256 checksum
How to use checksums
2a18db7cc68d2403bf19840d75d6c34ff9ed8ff64b44151897ef31f2f1a21eb1
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.1-py3-none-any.whl

Download URL txjsonrpc_ng-0.9.1-py3-none-any.whl
Size 18.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2778e467f53de6b37f661326cd67b491afb4ef1fec87c3c1cd736cc8da7f3fa5
BLAKE2b-256 checksum
How to use checksums
bc1eb63acea6357193ad31e92e44a36f4f255bcb5713a79891ec5a1588a8b320
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

This release

0.9.1 This release

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