Skip to main content

A simple JSON-RPC server

Project description

JSON-RPC Server for Python

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.

Features

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

Installation

To install the JSON-RPC Server, simply use pip:

pip install jsonrpc-server-py

Quick Start

Define 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)

Example

Request:

{
  "jsonrpc": "2.0",
  "method": "add",
  "params": [1, 2],
  "id": 1
}

Result:

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

Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues to improve the project.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jsonrpc-server-py-0.2.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jsonrpc_server_py-0.2.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file jsonrpc-server-py-0.2.0.tar.gz.

File metadata

  • Download URL: jsonrpc-server-py-0.2.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.8.10

File hashes

Hashes for jsonrpc-server-py-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f9526a89feebd041967f211d5d8dc3a165aa5c7598f514d4faeee85f32ba4c7c
MD5 89b4a98eaa3d8d42a9f7a267018da35c
BLAKE2b-256 d589b29826d1e6140ca5f5f7a0a9b6a4622aae688222a7084dd15220a36fad6a

See more details on using hashes here.

File details

Details for the file jsonrpc_server_py-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for jsonrpc_server_py-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c2ae2d4e6859373eb38a90c6dd7aa427b2b2737636a02ccc6ac93b76b7f657e7
MD5 baf87f5bdfabf54ab074f2a99fe895e0
BLAKE2b-256 ef4b18fe22c94b452d4d268e3d450ec1925cde87eb4cebe61d1a92715990db27

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page