A reusable FastAPI application factory
Project description
FastAPI Template
A reusable FastAPI application factory packaged for quick reuse. The package exposes a
single public function, create_app, which returns a fully configured FastAPI
instance with logging, metrics, documentation, and health-check routes ready to go.
🚀 Quick Start
Installation
pip install horizon-fastapi-template
Usage
Create a new file (for example main.py) and bootstrap your API:
from horizon_fastapi_template import create_app
app = create_app()
Run the application with Uvicorn:
uvicorn main:app --reload
🔧 Configuration
Application behaviour is configured through environment variables using
pydantic-settings.
Create a .env file alongside your application if you need to override defaults:
PORT=8000
LOG_LEVEL=INFO
APP_NAME=MyFastAPIApp
PROCESS_TIME_HEADER=X-Process-Time
SWAGGER_STATIC_FILES=/static/swagger
SWAGGER_OPENAPI_JSON_URL=/openapi.json
LOG_REQUEST_EXCLUDE_PATHS=["/health", "/metrics", "/static", "/docs", "/redoc", "/openapi.json", "/.well-known"]
The same settings object is used internally to configure logging, documentation,
and middleware. Although the implementation lives under fastapi_template._internal,
those modules are considered private and may change without notice.
🧩 Features
- Logging – Structured logging powered by
loguruwith an optional request logging middleware. - Monitoring – Prometheus-compatible metrics endpoint and uptime background task ready to register in your observability stack.
- Documentation – Swagger UI and ReDoc served through customisable static assets bundled with the package.
- Middleware – Request timing, exception handling, and request logging middleware that can be toggled through configuration flags.
- Utilities – Helper clients for HTTP APIs, Bitbucket API, FTP servers, and Kubernetes interactions, plus shared Pydantic models for error responses.
📁 Project Structure
FastApiTemplate/
├── app/
│ └── main.py # Example application entrypoint
├── package/
│ └── fastapi_template/
│ ├── __init__.py # Public package exposing `create_app`
│ ├── utils.py # Public utility functions and classes
│ ├── _internal/ # Private framework modules
│ └── static/ # Bundled static assets for Swagger UI
├── pyproject.toml # Packaging metadata
├── requirements.txt # Pinning dependencies for development
└── README.md
🛠️ Development
Install dependencies in editable mode when working on the package:
pip install -e .
Run the example application from the repository root:
python -m app.main
📄 License
Distributed under the terms of the MIT license. See the 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 horizon_fastapi_template-0.0.5.dev1.tar.gz.
File metadata
- Download URL: horizon_fastapi_template-0.0.5.dev1.tar.gz
- Upload date:
- Size: 1.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb5dbc89baabe9d5f2d9ac552a2255b20690991a671ba6faa09c446dc70c6435
|
|
| MD5 |
645e3d166bbfd51f522da4b1ed6e2529
|
|
| BLAKE2b-256 |
3f6aa8c57132e8418c907aa6ffa241a54ed5e222f07ec22ef54b32baf2fbbf34
|
Provenance
The following attestation bundles were made for horizon_fastapi_template-0.0.5.dev1.tar.gz:
Publisher:
python-publish.yml on chaimmendelson/FastApiTemplate
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
horizon_fastapi_template-0.0.5.dev1.tar.gz -
Subject digest:
fb5dbc89baabe9d5f2d9ac552a2255b20690991a671ba6faa09c446dc70c6435 - Sigstore transparency entry: 601381578
- Sigstore integration time:
-
Permalink:
chaimmendelson/FastApiTemplate@28152a08f083134f7f2d880c7dfabfe22deb81e4 -
Branch / Tag:
refs/tags/0.0.5.dev1 - Owner: https://github.com/chaimmendelson
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@28152a08f083134f7f2d880c7dfabfe22deb81e4 -
Trigger Event:
release
-
Statement type:
File details
Details for the file horizon_fastapi_template-0.0.5.dev1-py3-none-any.whl.
File metadata
- Download URL: horizon_fastapi_template-0.0.5.dev1-py3-none-any.whl
- Upload date:
- Size: 1.8 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c47d8eb6af0737ec7df8ecad7968b8ac653cf9eeba9609aa94a676525e5904f
|
|
| MD5 |
042e561bb57d81281a235ac70d8b9584
|
|
| BLAKE2b-256 |
946f2d2e5635749e8f7e42175ebd490e7d788a01592d26f70f9cb1c730dc7629
|
Provenance
The following attestation bundles were made for horizon_fastapi_template-0.0.5.dev1-py3-none-any.whl:
Publisher:
python-publish.yml on chaimmendelson/FastApiTemplate
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
horizon_fastapi_template-0.0.5.dev1-py3-none-any.whl -
Subject digest:
8c47d8eb6af0737ec7df8ecad7968b8ac653cf9eeba9609aa94a676525e5904f - Sigstore transparency entry: 601381579
- Sigstore integration time:
-
Permalink:
chaimmendelson/FastApiTemplate@28152a08f083134f7f2d880c7dfabfe22deb81e4 -
Branch / Tag:
refs/tags/0.0.5.dev1 - Owner: https://github.com/chaimmendelson
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@28152a08f083134f7f2d880c7dfabfe22deb81e4 -
Trigger Event:
release
-
Statement type: