Transport agnostic framework for developing OpenRPC servers.
Project description
Python OpenRPC
Documentation: https://python-openrpc.burkard.cloud
Source Code: https://gitlab.com/mburkard/openrpc
Python OpenRPC is a transport agnostic framework for quickly and easily developing OpenRPC servers in Python.
Requirements
- Python 3.9+
- Pydantic for data models.
Installation
OpenRPC is on PyPI and can be installed with:
pip install openrpc
Or with Poetry
poetry add openrpc
Example
This is a minimal OpenRPC server hosted over HTTP and WebSockets using Tabella and uvicorn.
from openrpc import RPCServer
import tabella
rpc = RPCServer(title="DemoServer", version="1.0.0")
@rpc.method()
async def add(a: int, b: int) -> int:
return a + b
app = tabella.get_app(rpc)
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8080)
Example In
{
"id": 1,
"method": "add",
"params": {
"a": 1,
"b": 3
},
"jsonrpc": "2.0"
}
Example Result Out
{
"id": 1,
"result": 4,
"jsonrpc": "2.0"
}
Template App
A template app is available as an example or to clone to bootstrap your RPC server.
Support the Developer
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file openrpc-10.3.9.tar.gz
.
File metadata
- Download URL: openrpc-10.3.9.tar.gz
- Upload date:
- Size: 17.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.9.17 Linux/5.15.154+
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85c14a8d35095e91a6da21b0625c37914f5c273d0979100f579dd96a9d101695 |
|
MD5 | 7eae7dc13aab8da88d13aca7b2c4e833 |
|
BLAKE2b-256 | cda9836528e00f51bdb6b3c854db0f583355c6b7626c64ca9928b7610eaa4363 |
File details
Details for the file openrpc-10.3.9-py3-none-any.whl
.
File metadata
- Download URL: openrpc-10.3.9-py3-none-any.whl
- Upload date:
- Size: 21.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.9.17 Linux/5.15.154+
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6565d238a8465ea1244d1cf3f871b5531bdc1e2b2e6ab95c839e807e0415160 |
|
MD5 | 3ea4452c0c998321ecdcade4afc06626 |
|
BLAKE2b-256 | 94eb053f263b6ec6b3dd5baa62a830e7a2f43aaee8e82831726a07fc33433497 |