Skip to main content

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

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

  1. Clone the repository
  2. Install dependencies:
uv sync

Running Tests

pytest

License

MIT License - see LICENSE file for details

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_sdk-0.2.1.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

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

fastapi_sdk-0.2.1-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

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

Hashes for fastapi_sdk-0.2.1.tar.gz
Algorithm Hash digest
SHA256 777a82af8a9c9e1d965a9970e87da973136c6ddacb30175dafe4988056e9abde
MD5 6219579d97d55af319d276362c913dac
BLAKE2b-256 523e96d0a4d56e256ea045bfb29fc67c233aa3a6eb560f209c7e2ba4eb521e25

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastapi_sdk-0.2.1.tar.gz:

Publisher: python-publish.yml on Studio-Piot/fastapi-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for fastapi_sdk-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9486ba9b9822e417b16e36184f126590c7fb2208b4eb900c732abc88b57cfe4d
MD5 2d844238143dd7efd458aaa538a3a65d
BLAKE2b-256 0c9e53618022eb5a2cca4254118bfda8516461c390779ba5848819f0f611af8f

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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