A lightweight, easy-to-use JSON-RPC 2.0 server implementation in Python, designed for simplicity and minimal dependencies. This package allows you to quickly set up a JSON-RPC server to handle remote procedure calls in a standardized way, supporting both single and batch requests.
- Simple and straightforward JSON-RPC 2.0 compliance.
- Supports method registration for handling RPC calls.
- Handles single and batch requests.
- Built-in support for notifications (requests without response).
- Easy integration into existing Python applications.
Refer here for details: https://www.jsonrpc.org/specification
To install the JSON-RPC Server, simply use pip:
pip install jsonrpc-server-pyDefine the methods you want to expose through JSON-RPC, register your methods with the server, and run the server
from jsonrpc_server import register_method, run
def add(a, b):
return a + b
register_method('add', add)
if __name__ == "__main__":
run(address='localhost', port=8000)Request:
{
"jsonrpc": "2.0",
"method": "add",
"params": [1, 2],
"id": 1
}Result:
{
"jsonrpc": "2.0",
"result": 3,
"id": 1
}Contributions are welcome! Please feel free to submit pull requests or open issues to improve the project.
This project is licensed under the MIT License - see the LICENSE file for details.