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.7.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.7-cp38-abi3-win_arm64.whl (579.1 kB view details)

Uploaded CPython 3.8+Windows ARM64

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

Uploaded CPython 3.8+Windows x86-64

rustapi-0.1.7-cp38-abi3-musllinux_2_28_x86_64.whl (752.0 kB view details)

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

rustapi-0.1.7-cp38-abi3-manylinux_2_28_x86_64.whl (743.7 kB view details)

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

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

Uploaded CPython 3.8+manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.8+macOS 11.0+ ARM64

rustapi-0.1.7-cp38-abi3-macosx_10_12_x86_64.whl (677.9 kB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: rustapi-0.1.7.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.7.tar.gz
Algorithm Hash digest
SHA256 8a02441923a9864e9f99b3027d317beb02b647019b3302ca4289186cbad6d568
MD5 ca066a16a233a97719d8da9d182152ed
BLAKE2b-256 d1c9a4d3221af28f451030e1af47d6150866aa5f004033aab59467e928726f2a

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustapi-0.1.7.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.7-cp38-abi3-win_arm64.whl.

File metadata

  • Download URL: rustapi-0.1.7-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.7-cp38-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 cd03abc51fafe6bd42a16be0fe304da4fedcbe4721d85b01987c7d7f57ea266e
MD5 517340996174a7bbfd418bcaeba94e64
BLAKE2b-256 dcd866da70cee94ec4263fea9152fa7464db6ce6c6086a3e02eefe06b63a4380

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustapi-0.1.7-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.7-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: rustapi-0.1.7-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.7-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 ad91ae34ad291c2e31cc6cfc131f1987c05fee40e88badeb5e26070db39968f4
MD5 45306552515d62ea084977d03d8e40a5
BLAKE2b-256 6146acb3795a838b534e19acdf3d62a13ebbb5675ff0ae3a1083b3f4b6347ffa

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustapi-0.1.7-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.7-cp38-abi3-musllinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rustapi-0.1.7-cp38-abi3-musllinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e0558fce2a01472d8e5b57670de7bfece3be09c892f08b5f0f4145828823b537
MD5 bcfa6db4644384cf46758a1883b53772
BLAKE2b-256 67f9e384742b86acc5d8784eec2cc24a8a81a161fc1b1ed760dd6deb5905b67f

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustapi-0.1.7-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.7-cp38-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rustapi-0.1.7-cp38-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8de6335ee8d28d855cf746647a97ead11d49e7e984761ea8db652789c11ff3d3
MD5 f45e72ad5b456d3c89a97696838469b2
BLAKE2b-256 e6d1e3bbff3e6cc5ca8918538fc628059d0b596e419cc61604095b0b66feec00

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustapi-0.1.7-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.7-cp38-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for rustapi-0.1.7-cp38-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2f193ed847ddbc2cce90f45678d934c81efcd7ef8afcd6fa7910ab949d5a294a
MD5 8fc4104b95603f7f7464d97aa16f292e
BLAKE2b-256 37063e80f5b9ad873c8ff42959dce1ac74b7eaece59bb6a05ed99d059e701078

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustapi-0.1.7-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.7-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rustapi-0.1.7-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3e8e73e05a2a39cc37a793ee1128889270c82a29b598cae365b5d8e1713d2860
MD5 2c1d722131035abe225fb8b7b03b36db
BLAKE2b-256 c0bb5ddf04817f85d99923956288d1cc64010f0878afdae27044bc21656c0c5c

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustapi-0.1.7-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.7-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for rustapi-0.1.7-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 43a52858bc6294bbea39a5b8f0fc8643d84bef69ed247bc4c8f65fee78281ca3
MD5 c52e04c2274ffba91fe444b073c91b70
BLAKE2b-256 722d8193248bc0c08fc5b0c6edffd1426ca2b0202ed271681144cf22a018b031

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustapi-0.1.7-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