Skip to main content

fastapi-crud-generator

Tests PyPI Python License: MIT

CRUD route generator for FastAPI. Point it at an ORM model and get a full set of endpoints — with filtering, sorting, pagination, and nested resources — without writing a single Pydantic schema by hand.

Works with SQLModel, SQLAlchemy, and Tortoise ORM.

What it does

  • Auto schemas — public, create, and update schemas are derived from the ORM model automatically
  • Filtering — every scalar field becomes a query parameter: ?status=published&author_id=5
  • Sorting?sort=created_at:desc or multiple: ?sort=published:desc&sort=title:asc
  • Pagination?page=2&per_page=20, response always includes total count
  • Nested resources/threads/{thread_id}/posts/{post_id} in three lines
  • Related data — fetch relations in one request via ?include=author&include=tags
  • Customizable — disable any endpoint, override any handler, replace any schema

Quick start

from fastapi import FastAPI
from fastapi_crud_generator import CRUDCollection
from fastapi_crud_generator.orm.sqlmodel import SQLModelAdapter

app = FastAPI()

crud = CRUDCollection(orm_adapter=SQLModelAdapter(model=Article, get_session=get_session))
app.include_router(crud.get_router(prefix="/articles", tags=["articles"]))

This registers five endpoints:

GET    /articles               # list: filtering, sorting, pagination
GET    /articles/{article_id}  # get one
POST   /articles               # create
PATCH  /articles/{article_id}  # partial update
DELETE /articles/{article_id}  # delete

Request and response schemas are generated from the Article model automatically — no ArticleCreate, ArticleUpdate, or ArticlePublic classes needed.

Nested resources

thread_crud = CRUDCollection(orm_adapter=SQLModelAdapter(model=Thread, get_session=get_session))
post_crud   = CRUDCollection(orm_adapter=SQLModelAdapter(model=Post,   get_session=get_session))

thread_crud.add_nested_collection("/posts", post_crud)
app.include_router(thread_crud.get_router(prefix="/threads"))

This gives you the full hierarchy:

GET    /threads
GET    /threads/{thread_id}
POST   /threads
PATCH  /threads/{thread_id}
DELETE /threads/{thread_id}

GET    /threads/{thread_id}/posts
GET    /threads/{thread_id}/posts/{post_id}
POST   /threads/{thread_id}/posts
PATCH  /threads/{thread_id}/posts/{post_id}
DELETE /threads/{thread_id}/posts/{post_id}

Filtering, sorting, and pagination work on nested routes too. Post queries are automatically scoped to the parent thread.

Installation

If SQLModel, SQLAlchemy, or Tortoise is already in your project:

pip install fastapi-crud-generator

To install an ORM together with the package:

pip install "fastapi-crud-generator[sqlmodel]"
pip install "fastapi-crud-generator[sqlalchemy]"
pip install "fastapi-crud-generator[tortoise]"

Documentation

mozgsml.github.io/fastapi_crud_generator

License

MIT

Release files for fastapi-crud-generator 0.2.1

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

Source distribution (sdist)

Source distribution for fastapi-crud-generator 0.2.1
File Size Uploaded
fastapi_crud_generator-0.2.1.tar.gz 126.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fastapi-crud-generator 0.2.1
File Interpreter ABI Platform
fastapi_crud_generator-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 161.1 kB

Release files / fastapi_crud_generator-0.2.1.tar.gz

Download URL fastapi_crud_generator-0.2.1.tar.gz
Size 126.5 kB
Tags Source
SHA-256 checksum
How to use checksums
0837046c9603f34c6bfde01ba25e077ec30d13c66dc9d7b42980831ebdafe618
BLAKE2b-256 checksum
How to use checksums
a041b094b8b39db2f1d3ee4cf6bfba2fd175e6c799b81faf4c51d7239ae29ffb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.

Transparency log

Release files / fastapi_crud_generator-0.2.1-py3-none-any.whl

Download URL fastapi_crud_generator-0.2.1-py3-none-any.whl
Size 34.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
87bbcb1a21ea238cc3361b9017e3fce73c0a3c4f2429ce9e40eaf00fa30863ce
BLAKE2b-256 checksum
How to use checksums
fed688e09cb281cbb96252acfd62e36a8632445a90621711c7e56fd28b5e63e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.1

2 release files

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