Type-safe APIs
for Python.
Build APIs in Python and consume them in TypeScript with full inference. No schemas. No drift. No OpenAPI.
Everything you need.
Python defines the types. TypeScript consumes them, automatically.
Cross-language contracts.
Define once in Python. Get fully typed TypeScript contracts automatically.
Full IDE autocompletion.
Your Python procedures appear as typed methods. Rename a procedure and TypeScript flags every broken call.
Invalid Inputs? Blocked.
Bad data throws before it hits your logic - always. Powered by Pydantic v2.
Monorepo or Separate Repos - both work.
In a monorepo? The server writes typed contracts directly to the client. Separate repos? The client fetches them via HTTP at build time.
Universal Adapters.
Bring your own framework - FastAPI, Flask, Django, or raw ASGI. pyRPC fits your stack.
Modular Routers.
Organize procedures into isolated routers with prefixes. Merge them into a clean, namespaced root router.
Fits your stack.
pyRPC adapts to whatever backend and frontend you already use.
Ship in Three commands.
From zero to a running pyRPC server with a type-safe TypeScript client in under two minutes.
Add pyRPC to your Python project.
One command installs the core runtime with Pydantic-powered validation, async support, and framework adapters.
from pyrpc_core import rpc
@rpc
def greet(name: str) -> str:
return f"Hello {name}!"Start the pyRPC dev server.
Types are generated automatically as your server runs.
/**
* Auto-generated by pyrpc dev.
*/
export interface Types {
greet(name: string): Promise<string>;
}Ship type-safe TypeScript clients.
Install the client package in your frontend project. Types flow from Python to TypeScript - no manual codegen, no schema drift.
import { createClient } from "@pyrpc/client";
import type { Types } from "@pyrpc/types";
const client = createClient<Types>();
const result = await client.greet("World");
console.log(result); // "Hello World!"
pyRPC