Define your models. FlashAPI does the rest.
Project description
Define your models. FlashAPI does the rest.
Installation • Quick Start • Docs • Changelog
FlashAPI generates a full REST API with CRUD, pagination, filtering, sorting, full-text search, relations, and interactive documentation from your existing models — in one line.
Documentation
| Doc | Description |
|---|---|
| Integration Guide | Where to put FlashAPI in your project, new vs existing project, all 3 frameworks |
| Features | CRUD, pagination, filtering, sorting, search — detailed usage |
| Relations | Nested routes, expand, how relations are detected |
| Customization | Model wrapper, readonly, exclude, only, plural, response format, database |
| Authentication | How to protect endpoints (Django middleware, FastAPI deps, Flask before_request) |
| Custom Logic | How FlashAPI coexists with your business logic, when to use what |
| Framework Notes | Django, FastAPI, Flask specifics (serialization, URLs, field behavior) |
| Full Examples | E-commerce, school, restaurant, blog, SaaS, minimal todo |
Installation
pip install python-flashapi[fastapi] # or python-flashapi[django] or python-flashapi[flask] or python-flashapi[all]
Quick Start
FastAPI (new project)
# main.py
from pydantic import BaseModel
from flashapi.fastapi import FlashAPI
class Product(BaseModel):
name: str
price: float
in_stock: bool = True
app = FlashAPI(models=[Product]).app
uvicorn main:app --reload
# Open http://localhost:8000/docs
FastAPI (existing project)
# main.py — you already have app = FastAPI(...)
from fastapi import FastAPI
from flashapi.fastapi import FlashAPI
from models import Product, Order
app = FastAPI(title="My App")
# Your existing routes stay untouched
@app.get("/health")
async def health():
return {"ok": True}
# Mount FlashAPI under /api
flash = FlashAPI(models=[Product, Order])
app.mount("/api", flash.app)
See Integration Guide for all patterns (Option A/B/C).
Django
# urls.py
from django.urls import path, include
from flashapi.django import generate_urls
from myapp.models import Product, Order, Customer
urlpatterns = [
path("admin/", admin.site.urls),
path("api/", include(generate_urls(models=[Product, Order, Customer]))),
]
Open http://localhost:8000/api/docs/ for Swagger UI.
Flask
# app.py
from flask import Flask
from flashapi.flask import register_models
from models import Product, Order
app = Flask(__name__)
register_models(app, models=[Product, Order])
Open http://localhost:5000/docs for Swagger UI.
What you get
For every model, FlashAPI generates:
GET /{plural}/ → List (paginated, filterable, sortable, searchable)
POST /{plural}/ → Create
GET /{plural}/{id}/ → Read
PUT /{plural}/{id}/ → Update
DELETE /{plural}/{id}/ → Delete
GET /{parent}/{id}/{children}/ → Nested list (auto-detected relations)
Plus: ?expand=relation to inline related objects, and Swagger UI docs.
Model support
| Type | Detection | Storage |
|---|---|---|
| Django Model | _meta attribute |
Django ORM (your DB) |
| SQLAlchemy | __table__ attribute |
Your SQLAlchemy engine |
| Pydantic | model_fields attribute |
Auto SQLite |
| dataclass | @dataclass |
Auto SQLite |
Customization
from flashapi import Model
FlashAPI(models=[
Product, # Full CRUD
Model(Order, exclude=["delete"]), # No delete
Model(Config, readonly=True), # GET only
Model(Log, only=["list"]), # List only
Model(Animal, plural="animaux"), # Custom plural
])
See Customization docs for all options.
Authentication
FlashAPI does NOT handle auth. You protect routes using your framework's standard mechanisms:
- Django: middleware (example)
- FastAPI: dependencies / middleware (example)
- Flask:
before_request(example)
See Authentication docs for full examples including RBAC, JWT, API keys.
Custom business logic
FlashAPI does not interfere with your project. Add custom endpoints alongside:
# FlashAPI handles CRUD
flash = FlashAPI(models=[Product, Order])
app = flash.app
# You handle business logic
@app.post("/checkout")
async def checkout(request):
# Payment, emails, inventory...
return {"order_id": 42}
See Custom Logic docs for patterns and decision guide.
Philosophy
- FlashAPI handles CRUD, you handle business logic. No black magic, no monkey-patching.
- Zero intrusion. Does not modify your models, migrations, or existing code.
- Composable. Use it for 2 models or 20. Mix with custom endpoints freely.
- No opinion on auth. Your project, your rules.
- Framework-native. Generates standard routes. No lock-in, no proprietary runtime.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_flashapi-0.1.1.tar.gz.
File metadata
- Download URL: python_flashapi-0.1.1.tar.gz
- Upload date:
- Size: 52.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
239ecbe4860c0ba11f243d458ba2bcd6c5dc1d63aa3c767fa8d47e205cc077b8
|
|
| MD5 |
e0f2b91ad16a195a8e89dbe5b38718b8
|
|
| BLAKE2b-256 |
c45321b52e55e287bb0402f8cd0322ed4c9476807f1f621593ed07e6770aeae1
|
File details
Details for the file python_flashapi-0.1.1-py3-none-any.whl.
File metadata
- Download URL: python_flashapi-0.1.1-py3-none-any.whl
- Upload date:
- Size: 34.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42f0f5374a5a5738f2d4e850f61775546c3154cdb7805d654258960fd9e049fb
|
|
| MD5 |
3719c429d213f4321f614c83f52daa3c
|
|
| BLAKE2b-256 |
123020005ccebd38307083c31620a090bd8cf92a1c42a93302f0697d3ab4f856
|