Skip to main content

Define your models. FlashAPI does the rest.

Project description

FlashAPI

Define your models. FlashAPI does the rest.

PyPI version CI Python versions License

InstallationQuick StartDocsChangelog


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 flashapi[fastapi]   # or flashapi[django] or flashapi[flask] or 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


Download files

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

Source Distribution

python_flashapi-0.1.0.tar.gz (52.4 kB view details)

Uploaded Source

Built Distribution

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

python_flashapi-0.1.0-py3-none-any.whl (34.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: python_flashapi-0.1.0.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

Hashes for python_flashapi-0.1.0.tar.gz
Algorithm Hash digest
SHA256 54fbf483eb35fcc04e21555e5fced1d9eedb4b56d8ddfb8765c60537b146a2cd
MD5 5d103c1a3d289c95f49bb44b60090fa1
BLAKE2b-256 4bffc1b333a991d0599e704cfaf9690b7f945c3a5116ab6cf5f3bc7f01635eed

See more details on using hashes here.

File details

Details for the file python_flashapi-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for python_flashapi-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f61d0f706d3fbe6aeb66369d7bbaf46113d9351a1c6a3dad83f8863dafe919b6
MD5 195a01d87fb2a917cfd7279641e8b9b2
BLAKE2b-256 259d2bb50cc969c2eef849e3bd7ce4a842293b25103c9721dca6571aca392488

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