Skip to main content

A Rust-core Python web framework. Hot paths in Rust, business logic in Python.

Project description

rustapi

PyPI version PyPI pyversions PyPI platforms License: MIT OR Apache-2.0 CI Release Documentation Changelog

A Rust-core Python web framework. Hot paths in Rust, business logic in Python.

Status: Alpha. This is a foundational MVP demonstrating the architecture thesis — a Rust-native HTTP engine exposed through a Python decorator API with a single FFI hop per request. The full feature set (HTTP/3, async ORM, GraphQL, gRPC, native OpenTelemetry) is on the roadmap; see docs/ROADMAP.md.

Install

pip install rustapi

For local development:

git clone https://github.com/rustapi/rustapi
cd rustapi
maturin develop --release

Quick start

from rustapi import RustApi, Request, JsonResponse

app = RustApi()

@app.get("/")
async def index(request: Request):
    return {"hello": "world"}

@app.get("/users/{id}")
async def get_user(request: Request):
    user_id = request.path_params["id"]
    return {"id": int(user_id), "name": "Alice"}

@app.post("/echo")
async def echo(request: Request):
    body = await request.json()
    return JsonResponse({"echoed": body})

if __name__ == "__main__":
    app.run(host="127.0.0.1", port=8080)

Run it:

python app.py
# In another shell:
curl http://127.0.0.1:8080/
curl http://127.0.0.1:8080/users/42
curl -X POST http://127.0.0.1:8080/echo -d '{"msg":"hi"}'

Architecture

┌──────────────────────────────────────────────────────────┐
│  Rust engine (single binary, tokio runtime)              │
│  ┌──────────┐  ┌─────────┐  ┌──────────┐  ┌──────────┐  │
│  │ hyper +  │→ │ matchit │→ │  serde   │→ │ hyper    │  │
│  │ tokio    │  │ router  │  │ serialize│  │ response │  │
│  └──────────┘  └─────────┘  └──────────┘  └──────────┘  │
│                       │                                  │
│                       ▼                                  │
│            ┌────────────────────┐                        │
│            │  PyO3 FFI bridge   │  ← single hop per req  │
│            └────────────────────┘                        │
└──────────────────────────────────────────────────────────┘
                       │
                       ▼
┌──────────────────────────────────────────────────────────┐
│  Python layer (thin)                                     │
│  @app.get @app.post ... decorator API                    │
│  user handlers (async or sync)                           │
└──────────────────────────────────────────────────────────┘

What's implemented (v0.1)

  • HTTP/1.1 server via hyper + tokio
  • Radix-tree router via matchit (path params, 404 vs 405)
  • PyO3 bridge with sync and async Python handlers
  • JSON serialization via Python's json module
  • Response / JsonResponse / TextResponse types
  • Request with method, path, query_params, path_params, headers, body, .json(), .text()
  • Single-FFI-hop request dispatch

Roadmap

See docs/ROADMAP.md for the full plan. Highlights:

  • HTTP/2 + HTTP/3 (h3/quinn)
  • Tower middleware stack (CORS, CSRF, rate-limit, compression)
  • Async ORM (sqlx-based, Django-style API)
  • Native JWT/OAuth2/OIDC
  • WebSocket + SSE
  • OpenTelemetry-native tracing/metrics/logs
  • FastAPI/Flask/Django compatibility adapters
  • simd-json for response serialization
  • forge/rustapi CLI (new, serve, migrate, bench)

License

Dual-licensed under MIT OR Apache-2.0.

Contributions are accepted under the same dual license unless explicitly stated otherwise.

Contributing

See CONTRIBUTING.md. The short version: open an issue first, fork the repo, run cargo fmt && cargo clippy && cargo test && python tests/test_e2e.py before submitting a PR.

Security

Found a vulnerability? See SECURITY.md. Do not open a public issue for security problems.

Changelog

See CHANGELOG.md.

Publishing

Releases are built by GitHub Actions and published to PyPI via Trusted Publishing (OIDC). Maintainers: see docs/PUBLISHING.md for setup and the release runbook.

Project details


Download files

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

Source Distribution

rustapi-0.1.0.tar.gz (86.4 kB view details)

Uploaded Source

Built Distributions

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

rustapi-0.1.0-cp38-abi3-win_arm64.whl (579.1 kB view details)

Uploaded CPython 3.8+Windows ARM64

rustapi-0.1.0-cp38-abi3-win_amd64.whl (601.8 kB view details)

Uploaded CPython 3.8+Windows x86-64

rustapi-0.1.0-cp38-abi3-musllinux_2_28_x86_64.whl (752.1 kB view details)

Uploaded CPython 3.8+musllinux: musl 2.28+ x86-64

rustapi-0.1.0-cp38-abi3-manylinux_2_28_x86_64.whl (743.6 kB view details)

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

rustapi-0.1.0-cp38-abi3-manylinux_2_28_aarch64.whl (716.6 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.28+ ARM64

rustapi-0.1.0-cp38-abi3-macosx_11_0_arm64.whl (641.6 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

rustapi-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl (678.5 kB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

Details for the file rustapi-0.1.0.tar.gz.

File metadata

  • Download URL: rustapi-0.1.0.tar.gz
  • Upload date:
  • Size: 86.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rustapi-0.1.0.tar.gz
Algorithm Hash digest
SHA256 92a1e025519657b213359bed4a19814a17b46991866b416d209fe37df8f84ad0
MD5 c0be96fa240af88e62679aab7ed23664
BLAKE2b-256 e6cfd614173bb1af30a739284b426aab4fdb9af6ba2b5bb6df572012e87dd933

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustapi-0.1.0.tar.gz:

Publisher: release.yml on Piyush4u/rustapi

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

File details

Details for the file rustapi-0.1.0-cp38-abi3-win_arm64.whl.

File metadata

  • Download URL: rustapi-0.1.0-cp38-abi3-win_arm64.whl
  • Upload date:
  • Size: 579.1 kB
  • Tags: CPython 3.8+, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rustapi-0.1.0-cp38-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 585322e7b4bd2a3398229156a00e7e4e54ff6e21f5a9bd53a5ce2596839c6458
MD5 4e4b572041aa3119b984078eecd0d934
BLAKE2b-256 4c30afe399652ed54e52467bd145d1722e1b5d7452720cb0a83d506ef038e683

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustapi-0.1.0-cp38-abi3-win_arm64.whl:

Publisher: release.yml on Piyush4u/rustapi

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

File details

Details for the file rustapi-0.1.0-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: rustapi-0.1.0-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 601.8 kB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rustapi-0.1.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 90933fc1353b1eac303e326954060660d33bf48fd91942a711c7a7e134bad758
MD5 e99d408dfd486cdb06920737b60d6e51
BLAKE2b-256 939f69c439e9cc7ae14bb50f117b2201ed7f66a14ddeb76146e970f4edd8af2e

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustapi-0.1.0-cp38-abi3-win_amd64.whl:

Publisher: release.yml on Piyush4u/rustapi

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

File details

Details for the file rustapi-0.1.0-cp38-abi3-musllinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rustapi-0.1.0-cp38-abi3-musllinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 da4da4414a4bb1c710884a2e2041012af0830b1105d03bba8a0f8e34173e907c
MD5 abcdfab7b0cf98f57f1d28b48a0473b6
BLAKE2b-256 02546e044a8345d1d75964693ae996bc39772994214d4af70f5a812eda5207fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustapi-0.1.0-cp38-abi3-musllinux_2_28_x86_64.whl:

Publisher: release.yml on Piyush4u/rustapi

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

File details

Details for the file rustapi-0.1.0-cp38-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rustapi-0.1.0-cp38-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 603e5c9cefd3e7ae7f38ad6b76644005a1d30565c851b33d440303963120ec9a
MD5 1a697ea79f66d81e6ae35fb737ae1dfc
BLAKE2b-256 20b039642ae1a1a23325c363d178501e6d4d053a12774c7c8baf96b67cabdfa3

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustapi-0.1.0-cp38-abi3-manylinux_2_28_x86_64.whl:

Publisher: release.yml on Piyush4u/rustapi

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

File details

Details for the file rustapi-0.1.0-cp38-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for rustapi-0.1.0-cp38-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b83712593bacba26eae44c1af97fe48d6c648d2836d0483f0503af88845db289
MD5 366415a13eb2ab37b1e98bdace9c16b8
BLAKE2b-256 7796be5e189b06bde886cd928b880c07c1c6901c44986ae16ceac14622aa9f44

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustapi-0.1.0-cp38-abi3-manylinux_2_28_aarch64.whl:

Publisher: release.yml on Piyush4u/rustapi

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

File details

Details for the file rustapi-0.1.0-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rustapi-0.1.0-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 16f052b2bf189efa057b195de6454ce9bde5e7cb4483877fc5cc8761e75a6ee6
MD5 425d2760a00579e78ae51e789fe22c53
BLAKE2b-256 b054e6cad47cdafc1f932c4923b38fc4dad5a6969fcf9459390c5b3869781c6d

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustapi-0.1.0-cp38-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on Piyush4u/rustapi

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

File details

Details for the file rustapi-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for rustapi-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 78a1d3ac744ff0f38f9e95ff74979ecad1a6287cc42f24d83c6aef6841a5a181
MD5 746fa3186f0d2ffaf88c69472639c0e6
BLAKE2b-256 dc1caff323187afe32b7048e2f764e18edd3850a0fa80184d2fd6e844803c41b

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustapi-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on Piyush4u/rustapi

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