
Security News
New React Server Components Vulnerabilities: DoS and Source Code Exposure
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.
fastrapi
Advanced tools
FastrAPI is a high-performance web framework that supercharges your Python APIs with the power of Rust. Built on Axum and PyO3, it delivers unmatched speed, type safety, and developer-friendly Python syntax. Create robust, async-ready APIs with minimal overhead and maximum throughput. FastrAPI is your drop-in replacement for FastAPI, offering familiar syntax with up to 33x faster performance.
Yes. Powered by Rust and Axum, FastrAPI outperforms FastAPI by up to 33x in real-world benchmarks, with no compromises on usability. Check it out here

Nope. FastrAPI lets you write 100% Python code while leveraging Rust's performance under the hood.
Absolutely. With full Pydantic integration and async support, FastrAPI scales effortlessly for small projects and enterprise-grade APIs alike.
Yes. FastrAPI mirrors FastAPI's decorator-based syntax, ensuring compatibility and instant access to familiar workflows.
uv install fastrapi
pip install fastrapi
from fastrapi import FastrAPI
app = FastrAPI()
@app.get("/hello")
def hello():
return {"Hello": "World"}
@app.post("/echo")
def echo(data):
return {"received": data}
if __name__ == "__main__":
app.serve("127.0.0.1", 8080)
curl http://127.0.0.1:8080/hello
For the POST endpoint:
curl --location 'http://127.0.0.1:8080/echo' \
--header 'Content-Type: application/json' \
--data '{"foo": 123, "bar": [1, 2, 3]}'
from pydantic import BaseModel
from fastrapi import FastrAPI
api = FastrAPI()
class User(BaseModel):
name: str
age: int
@api.post("/create_user")
def create_user(data: User):
return {"msg": f"Hello {data.name}, age {data.age}"}
api.serve("127.0.0.1", 8080)
from fastrapi import FastrAPI
from fastrapi.responses import HTMLResponse, JSONResponse
api = FastrAPI()
@api.get("/html")
def get_html() -> HTMLResponse:
return HTMLResponse("<h1>Hello</h1>")
api.serve("127.0.0.1", 8080)
from fastrapi import FastrAPI
from fastrapi.responses import JSONResponse
from fastrapi.middleware import (
CORSMiddleware,
TrustedHostMiddleware,
GZipMiddleware,
SessionMiddleware
)
app = FastrAPI()
# TrustedHost Middleware
app.add_middleware(
TrustedHostMiddleware,
allowed_hosts=["127.0.0.1", "localhost", "127.0.0.1:8000"],
www_redirect=True
)
# CORS Middleware
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_methods=["GET", "POST"],
allow_headers=["*"],
allow_credentials=False
)
# 3. GZip Middleware
app.add_middleware(
GZipMiddleware,
minimum_size=500,
compresslevel=9
)
# 4. Session Middleware
app.add_middleware(
SessionMiddleware,
secret_key="super-duper-secret-key-change-this-in-prod-pwease-uwu-BUT-MAKE-IT-LONGER-NOW",
session_cookie="fastrapi_session",
max_age=3600,
https_only=False
)
# ROUTES
# WARNING: ALWAYS return JSONResponse if it's JSON, to ensure proper serialization
@app.get("/")
def index() -> JSONResponse:
return JSONResponse({"status": "running"})
@app.get("/heavy")
def heavy_data() -> JSONResponse:
# response large enough to trigger GZip compression
large_data = "x" * 1000
return JSONResponse({
"data": large_data,
"note": "Check content-encoding header!"
})
# Session Test: Increment a counter stored in the cookie
@app.get("/counter")
def session_counter(request) -> JSONResponse:
# For now, this verifies the Middleware sets the cookie correctly.
return JSONResponse({"message": "Session cookie should be set"})
if __name__ == "__main__":
app.serve("127.0.0.1", 8000)
# Test with:
# curl -v -H "Host: 127.0.0.1" http://127.0.0.1:8000/
# curl -v -H "Origin: http://example.com" http://127.0.0.1:8000/
Benchmarks using k6 show it outperforms FastAPI + Guvicorn across multiple worker configurations.
| Framework | Avg Latency (ms) | Median Latency (ms) | Requests/sec | P95 Latency (ms) | P99 Latency (ms) |
|---|---|---|---|---|---|
| FASTRAPI | 0.59 | 0.00 | 31360 | 2.39 | 11.12 |
| FastAPI + Guvicorn (workers: 1) | 21.08 | 19.67 | 937 | 38.47 | 93.42 |
| FastAPI + Guvicorn (workers: 16) | 4.84 | 4.17 | 3882 | 10.22 | 81.20 |
TLDR; FASTRAPI handles thousands of requests per second with ultra-low latency , making it ~33Ă— faster than FastAPI + Guvicorn with 1 worker.
Some advanced features are still in development like:
Contributions are welcome! Please feel free to submit a Pull Request.
Check out CONTRIBUTING.md for more details.
This project is licensed under the MIT License - see the LICENSE file for details.
Inspired by FastAPI Built with PyO3 and Axum
FAQs
A high-performance Python API framework powered by Rust
We found that fastrapi demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.