Skip to main content

A fast, expressive, Python-native web framework with auto OpenAPI docs.

Project description

🚀 Moxie API

A lightweight, high-performance, and "battery-included" ASGI web framework for Python. Built for modern development with a focus on speed, developer experience, and seamless integrations.

✨ Features

  • ⚡ High Performance: Built on top of anyio, httptools, and h11 for maximum throughput.
  • 🛡️ Type-Safe: Native support for Pydantic models with automatic request validation.
  • 🔌 Plugin System: Easily integrate with services like Supabase, Firebase, and SQLAlchemy.
  • 🛠️ Dependency Injection: Powerful and intuitive DI system with automatic parameter inference.
  • 🔒 Security First: Built-in support for JWT and API Key authentication.
  • 📦 Middleware: Robust middleware stack including CORS, GZip, TrustedHost, and more.
  • 📄 Auto OpenAPI: Automatic documentation generation (Swagger UI).
  • 🧪 Testing Suite: Built-in TestClient for effortless API testing.

🚀 Quickstart

Create a file named app.py:

from moxie import Moxie, Body
from pydantic import BaseModel

class Item(BaseModel):
    name: str
    price: float

app = Moxie(title="Moxie Demo")

@app.get("/")
async def root(name: str = "World"):
    return {"message": f"Welcome to Moxie, {name}!"}

@app.post("/items")
async def create_item(item: Item):
    return {"item": item, "status": "created"}

Run your API:

moxie dev app:app

Now visit http://127.0.0.1:8000/docs to see your interactive documentation!


🔌 Plugins See PLUGINS.MD for full details

Moxie makes it easy to integrate with your favorite services.

SQLAlchemy (Async)

from moxie.plugins.sqlalchemy import SQLAlchemyPlugin

db_plugin = SQLAlchemyPlugin(database_url="sqlite+aiosqlite:///./test.db")
app.install(db_plugin)

@app.get("/users")
async def get_users(db = Depends(db_plugin.get_db)):
    # db is an AsyncSession
    ...

Supabase

from moxie.plugins.supabase import SupabasePlugin

sb = SupabasePlugin(url="URL", key="KEY")
app.install(sb)

@app.get("/data")
async def data(client = Depends(sb.get_client)):
    ...

🧪 Testing

Testing is a first-class citizen in Moxie. Use the TestClient to test your endpoints without running a server:

from moxie.testing import TestClient
from app import app

client = TestClient(app)

def test_root():
    response = client.get("/?name=Developer")
    assert response.status_code == 200
    assert response.json()["message"] == "Welcome to Moxie, Developer!"

🧩 Middleware

Moxie includes several built-in middlewares:

from moxie.middleware import CORSMiddleware, GZipMiddleware

# Cross-Origin Resource Sharing
app.add_middleware(CORSMiddleware, allow_origins=["*"])

# Response Compression
app.add_middleware(GZipMiddleware, minimum_size=500)

🛠️ CLI Tools

Bootstrapping a new project is easy:

# Create a base project
moxie new my_project

# Create a project with a specific integration
moxie new my_db_project --template sqlalchemy

Other CLI commands:

  • moxie dev: Start the development server with auto-reload.
  • moxie routes: List all registered routes.
  • moxie openapi: Generate and export OpenAPI schema.

📜 License

Moxie is licensed under the MIT License. See the LICENSE file for more information.

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

moxie_api-2.0.6.tar.gz (30.6 kB view details)

Uploaded Source

Built Distribution

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

moxie_api-2.0.6-py3-none-any.whl (39.2 kB view details)

Uploaded Python 3

File details

Details for the file moxie_api-2.0.6.tar.gz.

File metadata

  • Download URL: moxie_api-2.0.6.tar.gz
  • Upload date:
  • Size: 30.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for moxie_api-2.0.6.tar.gz
Algorithm Hash digest
SHA256 1f67c3ae3263217e5a921afba3ad52950ab04b6f28b964f43013221883a25db6
MD5 a15571807ffec550e122169fc9bb446a
BLAKE2b-256 8b6c8b59bc366de2bceee1d6292cf03798dfdb8f0eba31392b34d43484b64246

See more details on using hashes here.

File details

Details for the file moxie_api-2.0.6-py3-none-any.whl.

File metadata

  • Download URL: moxie_api-2.0.6-py3-none-any.whl
  • Upload date:
  • Size: 39.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for moxie_api-2.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 5eb1ec7aaac49b738265a679f31ec4d1e399ab679458383cf7c63de10b676990
MD5 b7290ead4638ab3c0750f7079ee66767
BLAKE2b-256 1128e339bf9dd8cab7c2d3cda02cb912e9dd8ca08f497fbd59177f9b24a57f2d

See more details on using hashes here.

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