# Python OpenRPC
![](https://img.shields.io/badge/License-MIT-blue.svg)
![](https://img.shields.io/badge/code%20style-black-000000.svg)
![](https://img.shields.io/pypi/v/openrpc.svg)
![](https://img.shields.io/badge/coverage-100%25-success)
**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](https://open-rpc.org/) servers in Python.
## Requirements
- Python 3.9+
- [Pydantic](https://docs.pydantic.dev/latest/) for data models.
## Installation
OpenRPC is on PyPI and can be installed with:
```shell
pip install openrpc
```
Or with [Poetry](https://python-poetry.org/)
```shell
poetry add openrpc
```
## Example
This is a minimal OpenRPC server hosted over HTTP and WebSockets
using [Tabella](https://gitlab.com/mburkard/tabella)
and [uvicorn](https://www.uvicorn.org/).
```python
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
```json
{
"id": 1,
"method": "add",
"params": {
"a": 1,
"b": 3
},
"jsonrpc": "2.0"
}
```
Example Result Out
```json
{
"id": 1,
"result": 4,
"jsonrpc": "2.0"
}
```
## Template App
A [template app](https://gitlab.com/mburkard/openrpc-app-template) is available as an
example or to clone to bootstrap your RPC server.
## Support the Developer
<a href="https://www.buymeacoffee.com/mburkard" target="_blank">
<img src="https://cdn.buymeacoffee.com/buttons/v2/default-blue.png" alt="Buy Me a Coffee"
width="217"
height="60"/>
</a>
Raw data
{
"_id": null,
"home_page": "https://python-openrpc.burkard.cloud",
"name": "openrpc",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": null,
"author": "Matthew Burkard",
"author_email": "matthewjburkard@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/cd/a9/836528e00f51bdb6b3c854db0f583355c6b7626c64ca9928b7610eaa4363/openrpc-10.3.9.tar.gz",
"platform": null,
"description": "# Python OpenRPC\n\n![](https://img.shields.io/badge/License-MIT-blue.svg)\n![](https://img.shields.io/badge/code%20style-black-000000.svg)\n![](https://img.shields.io/pypi/v/openrpc.svg)\n![](https://img.shields.io/badge/coverage-100%25-success)\n\n**Documentation**: https://python-openrpc.burkard.cloud\n\n**Source Code**: https://gitlab.com/mburkard/openrpc\n\nPython OpenRPC is a transport agnostic framework for quickly and easily\ndeveloping [OpenRPC](https://open-rpc.org/) servers in Python.\n\n## Requirements\n\n- Python 3.9+\n- [Pydantic](https://docs.pydantic.dev/latest/) for data models.\n\n## Installation\n\nOpenRPC is on PyPI and can be installed with:\n\n```shell\npip install openrpc\n```\n\nOr with [Poetry](https://python-poetry.org/)\n\n```shell\npoetry add openrpc\n```\n\n## Example\n\nThis is a minimal OpenRPC server hosted over HTTP and WebSockets\nusing [Tabella](https://gitlab.com/mburkard/tabella)\nand [uvicorn](https://www.uvicorn.org/).\n\n```python\nfrom openrpc import RPCServer\nimport tabella\n\nrpc = RPCServer(title=\"DemoServer\", version=\"1.0.0\")\n\n\n@rpc.method()\nasync def add(a: int, b: int) -> int:\n return a + b\n\n\napp = tabella.get_app(rpc)\n\nif __name__ == \"__main__\":\n uvicorn.run(app, host=\"0.0.0.0\", port=8080)\n```\n\nExample In\n\n```json\n{\n \"id\": 1,\n \"method\": \"add\",\n \"params\": {\n \"a\": 1,\n \"b\": 3\n },\n \"jsonrpc\": \"2.0\"\n}\n```\n\nExample Result Out\n\n```json\n{\n \"id\": 1,\n \"result\": 4,\n \"jsonrpc\": \"2.0\"\n}\n```\n\n## Template App\n\nA [template app](https://gitlab.com/mburkard/openrpc-app-template) is available as an\nexample or to clone to bootstrap your RPC server.\n\n## Support the Developer\n\n<a href=\"https://www.buymeacoffee.com/mburkard\" target=\"_blank\">\n <img src=\"https://cdn.buymeacoffee.com/buttons/v2/default-blue.png\" alt=\"Buy Me a Coffee\"\n width=\"217\"\n height=\"60\"/>\n</a>\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Transport agnostic framework for developing OpenRPC servers.",
"version": "10.3.9",
"project_urls": {
"Homepage": "https://python-openrpc.burkard.cloud",
"Repository": "https://gitlab.com/mburkard/openrpc"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "94eb053f263b6ec6b3dd5baa62a830e7a2f43aaee8e82831726a07fc33433497",
"md5": "3ea4452c0c998321ecdcade4afc06626",
"sha256": "c6565d238a8465ea1244d1cf3f871b5531bdc1e2b2e6ab95c839e807e0415160"
},
"downloads": -1,
"filename": "openrpc-10.3.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3ea4452c0c998321ecdcade4afc06626",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 21327,
"upload_time": "2024-11-11T03:57:28",
"upload_time_iso_8601": "2024-11-11T03:57:28.543474Z",
"url": "https://files.pythonhosted.org/packages/94/eb/053f263b6ec6b3dd5baa62a830e7a2f43aaee8e82831726a07fc33433497/openrpc-10.3.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "cda9836528e00f51bdb6b3c854db0f583355c6b7626c64ca9928b7610eaa4363",
"md5": "7eae7dc13aab8da88d13aca7b2c4e833",
"sha256": "85c14a8d35095e91a6da21b0625c37914f5c273d0979100f579dd96a9d101695"
},
"downloads": -1,
"filename": "openrpc-10.3.9.tar.gz",
"has_sig": false,
"md5_digest": "7eae7dc13aab8da88d13aca7b2c4e833",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 17906,
"upload_time": "2024-11-11T03:57:30",
"upload_time_iso_8601": "2024-11-11T03:57:30.126617Z",
"url": "https://files.pythonhosted.org/packages/cd/a9/836528e00f51bdb6b3c854db0f583355c6b7626c64ca9928b7610eaa4363/openrpc-10.3.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-11 03:57:30",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "mburkard",
"gitlab_project": "openrpc",
"lcname": "openrpc"
}