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

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-as3445-0.8.8.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

fastapi_crudrouter_as3445-0.8.8-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file fastapi-crudrouter-as3445-0.8.8.tar.gz.

File metadata

File hashes

Hashes for fastapi-crudrouter-as3445-0.8.8.tar.gz
Algorithm Hash digest
SHA256 6db1f21cc517d0dec9f9494411c597c52891ed5530291a2a6bc0515a23014a69
MD5 0fb746123d6c3ad154a80af4b9893cee
BLAKE2b-256 6d94c1dd20fe5d4b5da2a4e46d843bb6e9d416dfe554eba6cd0f8003fc4c4037

See more details on using hashes here.

File details

Details for the file fastapi_crudrouter_as3445-0.8.8-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_crudrouter_as3445-0.8.8-py3-none-any.whl
Algorithm Hash digest
SHA256 da44e80b5ade920a137f1bd3694b7b3d9d97317270efa197218174ed53d8b67f
MD5 8e02a7d3861443e2b6825ce2148efbc5
BLAKE2b-256 4841ba2abc126c23d7d0c231c2453ec25eacba343797c4f6fc7b37c7aa5ae5e5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page