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 git+https://github.com/gclluch/jsonrpc-server.git

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.1.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.1-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: jsonrpc-server-py-0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 f0f223c92992ddcd9fc3d5967cca9ae2f2386050c09d084eb5bd667cbee2a3eb
MD5 2524c89f05966818825bea400fccc3f5
BLAKE2b-256 9c1403204dc4d3e0c9cb9f1da4824692829f46d60e1a0507ce35a28c10c13879

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for jsonrpc_server_py-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ed3b80e454f03bda014ec68544c4ecb42283f11eedf30ebbf910e8d16521d87e
MD5 b95916f7d39316c27fdb156cebdabd44
BLAKE2b-256 448c824445b9a91b79dc7660f635f5cd5d6c087f9d22bb4907a51cfa9e65ca85

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