Open-RPC API hosting and interactive documentation.
Project description
Tabella
Open-RPC development framework with builtin interactive documentation.
Install
Tabella is on PyPI and can be installed with:
pip install tabella
Or with Poetry
poetry add tabella
Python OpenRPC
The RPC server hosted and documented by Tabella is powered by Python OpenRPC. Refer to the Python OpenRPC docs hosted here for advanced use.
Getting Started
A basic Tabella app:
import tabella
from openrpc import RPCServer
import uvicorn
rpc = RPCServer()
@rpc.method()
def echo(a: str, b: float) -> tuple[str, float]:
"""Echo parameters back in result."""
return a, b
app = tabella.get_app(rpc)
if __name__ == "__main__":
uvicorn.run(app, host="127.0.0.1", port=8000)
Run this, then open http://127.0.0.1:8000/ in your browser to use the interactive documentation.
The Open-RPC API will be hosted over HTTP on http://127.0.0.1:8000/api
and over
WebSockets on ws://127.0.0.1:8000/api
.
Further Usage
Security and Depends Arguments
The tabella.get_app
function accepts argument, middleware
, which is a callable that
will be passed HTTP request headers/WebSocket connection headers. The middleware
function must return a tuple of two dictionaries, the first will be passed to the
RPC Server as
Depends Arguments
and the second as
Security Arguments.
Set Servers
Set RPC servers manually to specify transport and paths to host the RPC server on, e.g.
from openrpc import RPCServer, Server
import tabella
rpc = RPCServer(
servers=[
Server(name="HTTP API", url="http://localhost:8000/my/api/path"),
Server(name="WebSocket API", url="ws://localhost:8000/my/api/path"),
]
)
app = tabella.get_app(rpc)
This app will host the RPCServer over HTTP and over WebSockets with the
path /my/api/path
.
Pydantic
Pydantic is used for request/response deserialization/serialization as well as schema generation. Pydantic should be used for any models as seen here in the Python OpenRPC Docs.
FastAPI
Tabella HTTP and WebSocket server hosting is uses
FastAPI. The app returned by tabella.get_app
is a
FastAPI app.
Inspired By
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
Hashes for tabella-0.91.14-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6740327685a2043ea89a26dd314b1d9fc1a0a16188ea38a5407aee2b3c2bde69 |
|
MD5 | c0320d072dfb26c1bf8a0bb0e03a1e84 |
|
BLAKE2b-256 | 6f9d7cdcee1b59e1c80ac8f731d5ef4b3158c44d691c3252d5dd41e8ad1b993e |