Overview of Automatic CRUD Endpoints
mainFastCRUD automatically generates several standard RESTful endpoints for your FastAPI application. The available endpoints and their behaviors are:
Create
- Endpoint:
/{model} - Method:
POST - Request Body: JSON based on
create_schema. - Response: Returns the created item data if
select_schemais provided; otherwise returnsnull.
Read
- Endpoint:
/{model}/{id} - Method:
GET - Description: Retrieves a single item by its ID.
Read Multiple
- Endpoint:
/{model} - Method:
GET - Description: Retrieves multiple items with support for pagination and sorting.
- Query Parameters:
offset(optional): Starting point for fetching.limit(optional): Maximum items to return.page(optional): Page number (starts at 1).itemsPerPage(optional): Number of items per page.sort(optional): Sort fields. Format:field1,-field2(prefix-for descending).
Update
- Endpoint:
/{model}/{id} - Method:
PATCH - Request Body: JSON based on
update_schema. - Note: Returns 404 if the item is not found.
Delete
- Endpoint:
/{model}/{id} - Method:
DELETE - Description: Performs a soft delete if configured.
DB Delete (Hard Delete)
- Endpoint:
/{model}/db_delete/{id} - Method:
DELETE - Requirement: Requires a
delete_schemato be provided. - Description: Permanently removes the item from the database.