Overview

Building your API with Routers and Procedures.

Server

This section covers everything you need to build a pyRPC server.

What You'll Learn

  • Routers - The procedure registry, @rpc, and organizing procedures
  • Procedures - Defining procedures, types, sync vs async
  • Context - Accessing request and adapter context
  • Middleware - Framework middleware around your RPC endpoint
  • Adapters - FastAPI, Flask, Django, and ASGI integration

Quick Reference

from fastapi import FastAPI
from pyrpc_core import rpc
from pyrpc_fastapi import mount_fastapi

app = FastAPI()

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

mount_fastapi(app)

That's the core pattern: register with @rpc, mount with an adapter.