Skip to main content

PyPI version CI Python 3.8 to 3.14 Downloads per month License: MIT

jsonrpcserver

Process incoming JSON-RPC 2.0 requests in Python

Documentation | API reference | Examples | Changelog | Migration

jsonrpcserver takes a JSON-RPC 2.0 request, calls your Python function and gives you the response to send back. It leaves the networking to you, so it fits into whatever server you already have.

Features

  • Works with any framework or transport. The docs have tested examples for http.server, Flask, Werkzeug, Django, FastAPI, aiohttp, Sanic, Tornado, websockets, ZeroMQ and Socket.IO.
  • Sync and async: dispatch and async_dispatch. With async_dispatch, the requests in a batch run concurrently.
  • Follows the spec for batches, notifications and errors, and checks each request's params against your function's signature.
  • Keeps exception messages out of responses and in your logs, and limits batch size with max_batch_size (from 5.0.10).
  • Typed: ships py.typed, and @method keeps your functions' signatures for mypy and pyright.
  • Safe to call from several threads, and tested on Python 3.8 to 3.14, including free-threaded 3.14t.

Install

pip install jsonrpcserver

If you're on 5.0.9 or older, upgrade: those versions send exception messages to clients. The changelog lists what changed in 5.0.10.

Quickstart

Save this as server.py and run it with python server.py:

from jsonrpcserver import Result, Success, method, serve


@method
def ping() -> Result:
    return Success("pong")


if __name__ == "__main__":
    serve("localhost", 8000)

Then send it a request from another terminal:

curl -s -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0", "method": "ping", "id": 1}' http://localhost:8000/

Output:

{"jsonrpc": "2.0", "result": "pong", "id": 1}

serve() is a small server for trying things out. In your own framework, pass the request body to dispatch and send back the string it returns. The examples show how.

Security

Before you put a server on the internet, pass max_batch_size to dispatch and limit the request body size in your framework. Run 5.0.10 or later. The Security page explains why.

Documentation

See also

jsonrpcclient (GitHub) creates JSON-RPC requests and parses the responses in Python. It's the client-side companion to this library, and its quickstart talks to the server above.

Credits

Created by Beau Barker. Maintained by Synapse Research.

Metadata

Release files for jsonrpcserver 5.1.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 jsonrpcserver 5.1.0
File Size Uploaded Provenance Actions
jsonrpcserver-5.1.0.tar.gz 189.3 kB With provenance Details for jsonrpcserver-5.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for jsonrpcserver 5.1.0
File Interpreter ABI Platform Actions
jsonrpcserver-5.1.0-py3-none-any.whl Python 3 none any Details for jsonrpcserver-5.1.0-py3-none-any.whl

Total release size: 218.0 kB

Release files / jsonrpcserver-5.1.0.tar.gz

Download URL jsonrpcserver-5.1.0.tar.gz
Size 189.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4ae6de9734989a88843d98234d8bae62847f386589273c11a0a0f3f3d4558a45
BLAKE2b-256 checksum
How to use checksums
d8a23bd1a6532bf42e9be84aff5be652572d20ff5b65e9a6cdcd34bd1b7c2732
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

Release files / jsonrpcserver-5.1.0-py3-none-any.whl

Download URL jsonrpcserver-5.1.0-py3-none-any.whl
Size 28.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b77414fdfb5da8cab439612f23fabdbedffa14fc9b177ea7751f1412d675291a
BLAKE2b-256 checksum
How to use checksums
b1a0d239ebc252c0896f1d876f51b5ef8edec05f7e9015e07d12fc2f15e544f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

Security for jsonrpcserver 5.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for jsonrpcserver-5.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

5.1.0 This release

2 release files Full provenance

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