Skip to main content

🚀 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.

Metadata

Release files for moxie-api 2.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for moxie-api 2.0.6
File Size Uploaded Provenance Actions
moxie_api-2.0.6.tar.gz 30.6 kB Without provenance Details for moxie_api-2.0.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for moxie-api 2.0.6
File Interpreter ABI Platform Actions
moxie_api-2.0.6-py3-none-any.whl Python 3 none any Details for moxie_api-2.0.6-py3-none-any.whl

Total release size: 69.7 kB

Release files / moxie_api-2.0.6.tar.gz

Download URL moxie_api-2.0.6.tar.gz
Size 30.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1f67c3ae3263217e5a921afba3ad52950ab04b6f28b964f43013221883a25db6
BLAKE2b-256 checksum
How to use checksums
8b6c8b59bc366de2bceee1d6292cf03798dfdb8f0eba31392b34d43484b64246
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / moxie_api-2.0.6-py3-none-any.whl

Download URL moxie_api-2.0.6-py3-none-any.whl
Size 39.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5eb1ec7aaac49b738265a679f31ec4d1e399ab679458383cf7c63de10b676990
BLAKE2b-256 checksum
How to use checksums
1128e339bf9dd8cab7c2d3cda02cb912e9dd8ca08f497fbd59177f9b24a57f2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for moxie-api 2.0.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page