fastapi-jsonrpc

JSON-RPC server based on fastapi

Latest version: 3.5.0 registry icon
Maintenance score
81
Safety score
100
Popularity score
22
Check your open source dependency risks. Get immediate insight about security, stability and licensing risks.
Security
  Vulnerabilities
Version Suggest Low Medium High Critical
3.5.0 0 0 0 0 0
3.4.3 0 0 0 0 0
3.4.2 0 0 0 0 0
3.4.1 0 0 0 0 0
3.4.0 0 0 0 0 0
3.3.0 0 0 0 0 0
3.2.1 0 0 0 0 0
3.2.0 0 0 0 0 0
3.1.2 0 0 0 0 0
3.1.1 0 0 0 0 0
3.1.0 0 0 0 0 0
3.0.2 0 0 0 0 0
3.0.1 0 0 0 0 0
3.0.0b2 0 0 0 0 0
3.0.0b0 0 0 0 0 0
3.0.0 0 0 0 0 0
2.8.0 0 0 0 0 0
2.7.2 0 0 0 0 0
2.7.1 0 0 0 0 0
2.7.0 0 0 0 0 0
2.6.1 0 0 0 0 0
2.6.0 0 0 0 0 0
2.5.2 0 0 0 0 0
2.5.1 0 0 0 0 0
2.5.0 0 0 0 0 0
2.4.1 0 0 0 0 0
2.4.0 0 0 0 0 0
2.3.0 0 0 0 0 0
2.2.2 0 0 0 0 0
2.2.1 0 0 0 0 0
2.2.0 0 0 0 0 0
2.1.6 0 0 0 0 0
2.1.5 0 0 0 0 0
2.1.4 0 0 0 0 0
2.1.3 0 0 0 0 0
2.1.2 0 0 0 0 0
2.1.1 0 0 0 0 0
2.1.0 0 0 0 0 0
2.0.2 0 0 0 0 0
2.0.1 0 0 0 0 0
2.0.0 0 0 0 0 0
1.2.0 0 0 0 0 0
1.1.2 0 0 0 0 0
1.1.1 0 0 0 0 0
1.1.0 0 0 0 0 0
1.0.0 0 0 0 0 0
0.3.1 0 0 0 0 0
0.3.0 0 0 0 0 0
0.2.6 0 0 0 0 0
0.2.5 0 0 0 0 0
0.2.4 0 0 0 0 0
0.2.3 0 0 0 0 0
0.2.2 0 0 0 0 0
0.2.1 0 0 0 0 0
0.2.0 0 0 0 0 0
0.1.29 0 0 0 0 0
0.1.28 0 0 0 0 0
0.1.27 0 0 0 0 0
0.1.26 0 0 0 0 0
0.1.25 0 0 0 0 0
0.1.24 0 0 0 0 0
0.1.23 0 0 0 0 0
0.1.22 0 0 0 0 0
0.1.21 0 0 0 0 0
0.1.20 0 0 0 0 0
0.1.19 0 0 0 0 0
0.1.18 0 0 0 0 0
0.1.17 0 0 0 0 0
0.1.16 0 0 0 0 0
0.1.15 0 0 0 0 0
0.1.14 0 0 0 0 0
0.1.13 0 0 0 0 0
0.1.12 0 0 0 0 0
0.1.11 0 0 0 0 0
0.1.10 0 0 0 0 0
0.1.9 0 0 0 0 0
0.1.8 0 0 0 0 0
0.1.7 0 0 0 0 0
0.1.6 0 0 0 0 0
0.1.5 0 0 0 0 0
0.1.4 0 0 0 0 0
0.1.3 0 0 0 0 0
0.1.2 0 0 0 0 0
0.1.1 0 0 0 0 0
0.1.0 0 0 0 0 0

Stability
Latest release:

3.5.0 - This version is safe to use because it has no known security vulnerabilities at this time. Find out if your coding project uses this component and get notified of any reported security vulnerabilities with Meterian-X Open Source Security Platform

Licensing

Maintain your licence declarations and avoid unwanted licences to protect your IP the way you intended.

MIT   -   MIT License

Not a wildcard

Not proprietary

OSI Compliant



fastapi-jsonrpc

tests

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.

fastapi-jsonrpc Swagger UI

📚 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 endpoint
  • GET /docs — Swagger UI
  • GET /openapi.json — OpenAPI schema
  • GET /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 DataModel included in the schema.
  • Batch requests and notifications.
  • Context-manager JSON-RPC middlewares.
  • Optional Sentry integration (fastapi_jsonrpc.contrib.sentry.FastApiJsonRPCIntegration).
  • 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.