Skip to main content

A high-performance Python API framework powered by Rust

Project description

FastrAPI (Fast + Rust + API)

FastRAPI GIF 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.

Key Features

  • Lightning Speed: Powered by Rust and Axum, FastrAPI delivers up to 33x faster performance than FastAPI, making your APIs scream.
  • Python-First: Write clean, familiar Python code, no Rust knowledge needed. FastrAPI handles the heavy lifting behind the scenes.
  • Ironclad Type Safety: Inherits Rust's robust type system for rock-solid reliability, catching errors before they hit production.
  • Pydantic Powered: Seamless integration with Pydantic for effortless request and response validation, keeping your data in check.
  • Async Native: Built on Tokio's async runtime, FastrAPI maximizes concurrency for handling thousands of requests with ease.
  • Ultra Lightweight: Minimal runtime overhead with maximum throughput.
  • Drop-in Replacement: Drop-in compatibility with FastAPI's beloved decorator syntax, so you can switch without rewriting your codebase.

Is it as fast as claimed?

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

Do I need to know Rust?

Nope. FastrAPI lets you write 100% Python code while leveraging Rust's performance under the hood.

Can it handle complex APIs?

Absolutely. With full Pydantic integration and async support, FastrAPI scales effortlessly for small projects and enterprise-grade APIs alike.

Will it keep up with FastAPI updates?

Yes. FastrAPI mirrors FastAPI's decorator-based syntax, ensuring compatibility and instant access to familiar workflows.

Installation

uv

uv install fastrapi

pip

pip install fastrapi

Quick Start

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)

Now, test it with:

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]}'
Show Pydantic example
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)
Show ResponseTypes Example
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)

Performance

Benchmarks using k6 show it outperforms FastAPI + Guvicorn across multiple worker configurations.

🖥️ Test Environment

  • Kernel: 6.16.8-arch3-1
  • CPU: AMD Ryzen 7 7735HS (16 cores, 4.83 GHz)
  • Memory: 15 GB
  • Load Test: 20 Virtual Users (VUs), 30s

⚡ Benchmark Results

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.

Current Limitations

Some advanced features are still in development like:

  • Logging/metrics
  • Middleware
  • Websockets
  • Dependency injection
  • Static file serving
  • Rate limiter (even FastAPI doesn't have it)
  • Better error handling (currently shows Rust errors)
  • Background tasks
  • Testing support
  • GraphQL support
  • A nice logging tool

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  • Fork the repository
  • Create your feature branch (git checkout -b feature/amazing-feature)
  • Commit your changes (git commit -m 'Add some amazing feature')
  • Push to the branch (git push origin feature/amazing-feature)
  • Open a Pull Request

Check out CONTRIBUTING.md for more details.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Inspired by FastAPI Built with PyO3 and Axum

Star History

Star History Chart

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

fastrapi-0.2.1-cp39-abi3-win_amd64.whl (732.3 kB view details)

Uploaded CPython 3.9+Windows x86-64

fastrapi-0.2.1-cp39-abi3-manylinux_2_28_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.28+ x86-64

fastrapi-0.2.1-cp39-abi3-macosx_11_0_arm64.whl (966.6 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

File details

Details for the file fastrapi-0.2.1-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: fastrapi-0.2.1-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 732.3 kB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fastrapi-0.2.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 2f079d5dc9712512c0e347ffcd8723493935cd182fb28d325f242ee4e31211cc
MD5 76484f10a7154bbb18aec95ae0766487
BLAKE2b-256 2523fd592f39bbbef6f63085f1ef7ba98f6662133b39f0a96aad42c142a568f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastrapi-0.2.1-cp39-abi3-win_amd64.whl:

Publisher: CI.yml on ppmpreetham/fastrapi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastrapi-0.2.1-cp39-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fastrapi-0.2.1-cp39-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ad9693aa4c3cc2178adb820b74ad38a2ecd01471d72aca73df456e459c3553f8
MD5 1f0a147b944c7a09a5f35af6ee7a616e
BLAKE2b-256 f4a2c18f204f4d83032052adab572620ba9a6bbdfedbc2058b8ccd00c0b8158f

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastrapi-0.2.1-cp39-abi3-manylinux_2_28_x86_64.whl:

Publisher: CI.yml on ppmpreetham/fastrapi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastrapi-0.2.1-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fastrapi-0.2.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 76c7e8c46c19ed947cf9fb0d7adde9147e83a2a91ca6c21b5725683339c27d13
MD5 054d37202756ec164b0ac4187ad077fd
BLAKE2b-256 601c3f9d7c52aab680b5104fbccd873357032964823eeaa9de68b142c536c4bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastrapi-0.2.1-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: CI.yml on ppmpreetham/fastrapi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page