프로젝트
GitHub에서 보기
smagafurov/fastapi-jsonrpc
소개
fastapi 기반 JSON-RPC 서버
웹 및 앱 개발What you can do
- All of FastAPI — Depends, Body, Header, Cookie, Pydantic models, async/await.
- Auto-generated OpenAPI and OpenRPC schemas.
- Typed errors with Pydantic DataModel included in the schema.
- Batch requests and notifications.
측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
Originalfastapi-jsonrpc
JSON-RPC 2.0 server on top of FastAPI. Write JSON-RPC methods the same way you write FastAPI endpoints and get OpenAPI, Swagger UI and OpenRPC for free.

📚 Documentation: https://smagafurov.github.io/fastapi-jsonrpc/
Install
pip install fastapi-jsonrpc
Minimal example
import fastapi_jsonrpc as jsonrpc
from pydantic import BaseModel
from fastapi import Body
app = jsonrpc.API()
api_v1 = jsonrpc.Entrypoint('/api/v1/jsonrpc')
class MyError(jsonrpc.BaseError):
CODE = 5000
MESSAGE = 'My error'
class DataModel(BaseModel):
details: str
@api_v1.method(errors=[MyError])
def echo(data: str = Body(..., examples=['hello'])) -> str:
if data == 'error':
raise MyError(data={'details': 'boom'})
return data
app.bind_entrypoint(api_v1)
if __name__ == '__main__':
import uvicorn
uvicorn.run('app:app', port=5000, access_log=False)
Run it with uvicorn and open:
POST /api/v1/jsonrpc— JSON-RPC endpointGET /docs— Swagger UIGET /openapi.json— OpenAPI schemaGET /openrpc.json— OpenRPC schema
Features
- All of FastAPI —
Depends,Body,Header,Cookie, Pydantic models, async/await. - Auto-generated OpenAPI and OpenRPC schemas.
- Typed errors with Pydantic
DataModelincluded in the schema. - Batch requests and notifications.
- Context-manager JSON-RPC middlewares.
- Optional Sentry integration (
fastapi_jsonrpc.contrib.sentry.FastApiJsonRPCIntegration). - Optional OpenTelemetry integration — per-call traces, JSON-RPC error reporting and duration metrics. Install with
pip install 'fastapi-jsonrpc[opentelemetry]'. - Pytest plugin for capturing JSON-RPC errors in tests.
See the full docs at https://smagafurov.github.io/fastapi-jsonrpc/.
Development
# Install dependencies
uv sync --frozen --group dev
# Run tests
uv run --frozen python -m pytest
# Run a single test
uv run --frozen python -m pytest tests/test_jsonrpc.py::test_name -x
# Change dependencies — edit pyproject.toml, then:
uv lock
# Build and publish
uv build
uv publish
License
MIT — see LICENSE.
관련 프로젝트 살펴보기
불러오는 중…