Utilities for FastAPI projects.
Project description
FastAPI SDK
A powerful SDK for building FastAPI applications with built-in authentication, authorization, and CRUD operations.
Features
-
🔐 Authentication & Authorization
- JWT-based authentication
- Role-based access control
- Fine-grained permissions
- User claims management
-
🗄️ Database Operations
- Automatic CRUD operations
- Soft delete support
- Pagination
- Relationship handling
-
🛡️ Security
- Ownership-based access control
- Permission-based authorization
- Role-based access control
- Secure token handling
-
📝 Type Safety
- Pydantic model integration
- Type hints throughout
- Automatic validation
- OpenAPI documentation
Documentation
- Route Controller Documentation - Learn how to create CRUD routes with authentication and permissions
- Model Controller Documentation - Understand how to implement database operations and relationships
Installation
pip install fastapi-sdk
Quick Start
from fastapi import FastAPI
from fastapi_sdk.controllers.route import RouteController
from fastapi_sdk.middleware.auth import AuthMiddleware
app = FastAPI()
# Add authentication middleware
app.add_middleware(
AuthMiddleware,
public_routes=["/docs", "/openapi.json"], # Routes that don't require authentication
auth_issuer="https://your-auth-server.com", # The issuer of the JWT tokens
auth_client_id="your-client-id", # Your application's client ID
env="prod", # Environment: "test" or "prod"
# Optional: Test environment keys
test_private_key_path="path/to/private.key", # Only needed for test environment
test_public_key_path="path/to/public.key", # Only needed for test environment
)
# Create a route controller
account_routes = RouteController(
prefix="/accounts",
tags=["accounts"],
controller=AccountController,
get_db=get_db,
schema_response=AccountResponse,
schema_response_paginated=BaseResponsePaginated[AccountResponse],
schema_create=AccountCreate,
schema_update=AccountUpdate,
)
# Include routes
app.include_router(account_routes.router)
Development
Setup
- Clone the repository
- Install dependencies:
uv sync
Running Tests
pytest
License
MIT License - see LICENSE file for details
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastapi_sdk-0.2.1.tar.gz.
File metadata
- Download URL: fastapi_sdk-0.2.1.tar.gz
- Upload date:
- Size: 15.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
777a82af8a9c9e1d965a9970e87da973136c6ddacb30175dafe4988056e9abde
|
|
| MD5 |
6219579d97d55af319d276362c913dac
|
|
| BLAKE2b-256 |
523e96d0a4d56e256ea045bfb29fc67c233aa3a6eb560f209c7e2ba4eb521e25
|
Provenance
The following attestation bundles were made for fastapi_sdk-0.2.1.tar.gz:
Publisher:
python-publish.yml on Studio-Piot/fastapi-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastapi_sdk-0.2.1.tar.gz -
Subject digest:
777a82af8a9c9e1d965a9970e87da973136c6ddacb30175dafe4988056e9abde - Sigstore transparency entry: 184352066
- Sigstore integration time:
-
Permalink:
Studio-Piot/fastapi-sdk@ebfcb0ad7443926c4c5473770a0d94af181666a7 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/Studio-Piot
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@ebfcb0ad7443926c4c5473770a0d94af181666a7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file fastapi_sdk-0.2.1-py3-none-any.whl.
File metadata
- Download URL: fastapi_sdk-0.2.1-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9486ba9b9822e417b16e36184f126590c7fb2208b4eb900c732abc88b57cfe4d
|
|
| MD5 |
2d844238143dd7efd458aaa538a3a65d
|
|
| BLAKE2b-256 |
0c9e53618022eb5a2cca4254118bfda8516461c390779ba5848819f0f611af8f
|
Provenance
The following attestation bundles were made for fastapi_sdk-0.2.1-py3-none-any.whl:
Publisher:
python-publish.yml on Studio-Piot/fastapi-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastapi_sdk-0.2.1-py3-none-any.whl -
Subject digest:
9486ba9b9822e417b16e36184f126590c7fb2208b4eb900c732abc88b57cfe4d - Sigstore transparency entry: 184352073
- Sigstore integration time:
-
Permalink:
Studio-Piot/fastapi-sdk@ebfcb0ad7443926c4c5473770a0d94af181666a7 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/Studio-Piot
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@ebfcb0ad7443926c4c5473770a0d94af181666a7 -
Trigger Event:
release
-
Statement type: