Skip to main content

Interactive Documentation

Tabella provides generated interactive documentation for your RPC API.

A live demo is available here.

Using Tabella

First, install Tabella and uvicorn.

Pip

pip install tabella

Poetry

poetry add tabella

Run:

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

Then open http://127.0.0.1:8000/ to see the auto generated documentation.

Docs Demo

RPC Discover

The OpenRPC spec defines a method called rpc.discover, which returns an OpenRPC Document describing the API. This JSON document lists each method in the API, what params they expect and what results they produce.

Using Discover

The rpc.discover method is automatically generated for your API. This code:

from openrpc import RPCServer

rpc = RPCServer(title="RPCServer", version="1.0.0", debug=True)


@rpc.method()
def add(a: int, b: int) -> int:
return a + b


req = '{"id": 1, "method": "rpc.discover", "jsonrpc": "2.0"}'
print(rpc.process_request(req))

Will print the following OpenRPC document.

{
"id": 1,
"result": {
"openrpc": "1.2.6",
"info": {
"title": "RPCServer",
"version": "1.0.0"
},
"methods": [
{
"name": "add",
"params": [
{
"name": "a",
"schema": {
"type": "integer"
},
"required": true
},
{
"name": "b",
"schema": {
"type": "integer"
},
"required": true
}
],
"result": {
"name": "result",
"schema": {
"type": "integer"
},
"required": true
}
}
],
"components": {
"schemas": {}
}
},
"jsonrpc": "2.0"
}