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
While Python OpenRPC is a transport agnostic framework, if you're going to expose your RPC API over websockets or HTTP it is recommended you use Tabella which wraps this framework.
pip install tabella
Or with Poetry
poetry add tabella
Or to use the framework directly.
pip install openrpc
poetry add openrpc
Example
This is a minimal OpenRPC server hosted over HTTP and WebSockets using Tabella.
from tabella import Tabella
rpc = Tabella(title="DemoServer", version="1.0.0")
@rpc.method()
async def add(a: int, b: int) -> int:
return a + b
if __name__ == "__main__":
rpc.run()
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.