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
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.
The CRUDRouter is able to dynamically generate detailed documentation based on the models given to it.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file fastapi-crudrouter-async-0.8.6.tar.gz
.
File metadata
- Download URL: fastapi-crudrouter-async-0.8.6.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 426f3b57138ae2cf327c6b844320dc0ec51028fd6a1920bfc0ff3ca7b1df1bbc |
|
MD5 | 306b72f0f743bf07494656e47e256e62 |
|
BLAKE2b-256 | e3d56155c32486c5a4036f47dfeac45193addd5de6e8cfa733d014a54c553e88 |