Skip to main content

A dynamic FastAPI router that automatically creates CRUD routes for your models

Project description

⚡ Create CRUD routes with lighting speed
A dynamic FastAPI router that automatically creates CRUD routes for your models

Tests Downloads Package version License

PyPI - Python Version


Documentation: https://fastapi-crudrouter.awtkns.com

Source Code: https://github.com/awtkns/fastapi-crudrouter


Tired of rewriting generic CRUD routes? Need to rapidly prototype a feature for a presentation or a hackathon? Thankfully, fastapi-crudrouter has your back. As an extension to the APIRouter included with FastAPI, the FastAPI CRUDRouter will automatically generate and document your CRUD routes for you, all you have to do is pass your model and maybe your database connection.

FastAPI-CRUDRouter is lighting fast, well tested, and production ready.

Installation

pip install fastapi-crudrouter

Basic Usage

Below is a simple example of what the CRUDRouter can do. In just ten lines of code, you can generate all the crud routes you need for any model. A full list of the routes generated can be found here.

from pydantic import BaseModel
from fastapi import FastAPI
from fastapi_crudrouter import MemoryCRUDRouter as CRUDRouter

class Potato(BaseModel):
    id: int
    color: str
    mass: float

app = FastAPI()
app.include_router(CRUDRouter(schema=Potato))

Advanced Usage

fastapi-crudrouter provides a number of features that allow you to get the most out of your automatically generated CRUD routes. Listed below are some highlights.

  • Automatic Pagination (docs)
  • Ability to Provide Custom Create and Update Schemas (docs)
  • Dynamic Generation of Create and Update Schemas (docs)
  • Ability to Add, Customize, or Disable Specific Routes (docs)
  • Native Support for FastAPI Dependency Injection (docs)

Supported Backends / ORMs

fastapi-crudrouter currently supports a number of backends / ORMs. Listed below are the backends currently supported. This list will likely grow in future releases.

  • In Memory (docs)
  • SQLAlchemy (docs)
  • Databases (async) (docs)
  • Gino (async) (docs)
  • Ormar (async) (docs)
  • Tortoise ORM (async) (docs)

OpenAPI Support

By default, all routes generated by the CRUDRouter will be documented according to OpenAPI spec.

Below are the default routes created by the CRUDRouter shown in the generated OpenAPI documentation.

OpenAPI Route Overview

The CRUDRouter is able to dynamically generate detailed documentation based on the models given to it.

OpenAPI Route Detail

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

fastapi_crudrouter_v2-0.1.5.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

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

fastapi_crudrouter_v2-0.1.5-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_crudrouter_v2-0.1.5.tar.gz.

File metadata

  • Download URL: fastapi_crudrouter_v2-0.1.5.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.12.10 Windows/11

File hashes

Hashes for fastapi_crudrouter_v2-0.1.5.tar.gz
Algorithm Hash digest
SHA256 02f19a80e306c04f9659db4d07c68dbecfcfdc05f2b18b10ee2301b60491fa07
MD5 612b0a8aabdadce8f1c364aa6df1272d
BLAKE2b-256 71a8a16bc8f633841ef5217b11ced76744f8759b6fb3596f6bb6bc5ba377dc51

See more details on using hashes here.

File details

Details for the file fastapi_crudrouter_v2-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_crudrouter_v2-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d06547d7344a04ba2da3dc2f6026dcdafbadac79b6526a06dc94585e055f42ac
MD5 5ad887365fe38caf85d5a90d2d9d8d1d
BLAKE2b-256 377664411fe7d2d05a06769e311fb4f52c083c9981bf317f66e5fa3bc35717d7

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