The invisible bridge between Python and TypeScript. Get tRPC-like type safety without abandoning Python.
PolyRPC watches your Python files and generates TypeScript types in real-time. Save your FastAPI code, get instant autocomplete in your React app.
Python (FastAPI/Pydantic) → Rust Parser (<50ms) → TypeScript Types
npm install -g polyrpcpolyrpc init # Create config file
polyrpc watch # Watch and generate types
polyrpc generate # One-time generationPython:
class User(BaseModel):
id: int
name: str
email: str
@app.get("/users/{user_id}")
def get_user(user_id: int) -> User:
return users[user_id]Generated TypeScript:
export interface User {
id: number;
name: string;
email: string;
}
export const py = {
users: {
get_user: {
query: (input: { user_id: number }) => request<User>('GET', `/users/${input.user_id}`),
},
},
} as const;Usage:
const user = await py.users.get_user.query({ user_id: 1 });
// Full autocomplete, type-safe- Real-time type generation (<50ms)
- Zero build steps
- Query parameters support
- SSE/Streaming for AI apps
- Enums, unions, optionals
- Path parameters
Create polyrpc.toml:
[python]
source_dir = "./backend"
[typescript]
output_file = "./frontend/src/polyrpc.ts"
[api]
base_url = "http://localhost:8000"| Package | Install |
|---|---|
| CLI | npm i -g polyrpc |
| Rust Core | cargo install polyrpc-sentinel |
| React Hooks | npm i @polyrpc/react |
MIT