Skip to content

pRPC-dev/prpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pRPC

pRPC is a modern, tRPC-inspired "drop-in RPC layer" for Python. It's designed to be dead simple, type-safe, and framework-agnostic.

Inspired by giving you the best DX, pRPC focuses on giving you a type-safe bridge between your backend and frontend without forcing a specific architecture or framework.

Philosophy

  • Dead simple install: Zero config, zero ceremony.
  • Works everywhere: Plugs into FastAPI, Flask, or any ASGI server.
  • Batteries included but modular: Install only what you need.
  • Type-safe bridge: Get a tRPC-like experience with Python and TypeScript.

Modular Installation

pRPC follows a modular packaging strategy. You only pay for what you use.

1. Core (Required)

The tiny core protocol and runtime.

uv add prpc
# or
pip install prpc

2. Adapters (Optional)

Install the adapter for your favorite framework.

FastAPI

uv add prpc-fastapi

Flask

uv add prpc-flask

3. Codegen (Optional)

Tools for generating TypeScript clients.

uv add prpc-codegen

Quick Start

1. Server-side (FastAPI Example)

Define your procedures and mount the RPC layer.

from prpc import rpc
from prpc_fastapi import mount_fastapi
from fastapi import FastAPI

app = FastAPI()

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

mount_fastapi(app)

2. Client-side (Python)

Call your procedures with full type support and dynamic method discovery.

from prpc import RPCClient

with RPCClient("http://localhost:8000") as client:
    result = client.add(10, 5)
    print(f"Result: {result}")

3. Client-side (TypeScript)

Use the CLI to generate a type-safe TS client.

prpc codegen -m my_app.main -o client.ts

CLI Utilities

The prpc command (provided by prpc-codegen) allows you to:

  • prpc serve: Instantly host an RPC module.
  • prpc inspect: Visualize all registered procedures.
  • prpc codegen: Generate frontend clients.

Documentation & Examples

Check out the examples/ directory for complete server and client implementations.

License

MIT

CLI Usage

prpc --help

About

The best rpc framework for python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published