fastapi-crud-generator
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:descor multiple:?sort=published:desc&sort=title:asc - Pagination —
?page=2&per_page=20, response always includes totalcount - 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.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fastapi_crud_generator-0.2.0.tar.gz | 125.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fastapi_crud_generator-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 160.2 kB
Release files / fastapi_crud_generator-0.2.0.tar.gz
| Download URL | fastapi_crud_generator-0.2.0.tar.gz |
|---|---|
| Size | 125.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
250251c5f2ec1e99fdb78d752c60621c61cad1810fa266ada77bbb5f90677212
|
|
BLAKE2b-256 checksum How to use checksums |
5a3b87ba29f6a96b98884606319d1c006f7ed0981cce28b677d34ee5636d57c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.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 Jul 28, 2026.
Transparency logRelease files / fastapi_crud_generator-0.2.0-py3-none-any.whl
| Download URL | fastapi_crud_generator-0.2.0-py3-none-any.whl |
|---|---|
| Size | 34.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0c8a22f2b677bde881ff320e7de5d56497e4941cd83337979f8bbbf1888e08e7
|
|
BLAKE2b-256 checksum How to use checksums |
c199906c11d181317b0e8c64aa8289337f480d2ae1a859c85ec7d8c71c50d8f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.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 Jul 28, 2026.
Transparency log