Health check utilities for FastAPI applications.
Project description
fastapi-health-check
FastAPI health checks with a small public API, a visual status page, and JSON responses from the same endpoint.
Example interface
Installation
Install with uv:
uv add fastapi-ht
Install with pip:
pip install fastapi-ht
What the library provides
- A base contract for advanced checks
- A lightweight registry for collecting and running checks
- A single
/htendpoint with HTML by default - JSON responses when the client sends
Accept: application/json - A simple way to monitor any custom area of your system
Important note
The library does not ship with a database check by default.
The only built-in check today is AppAliveCheck, which reports that the application is up. Database, Redis, queues, external APIs, or any other monitored area are meant to be registered by the user.
Quick start
from fastapi import FastAPI
from fastapi_health_check import AppAliveCheck, HealthRegistry, health_check, install_health_check
app = FastAPI()
registry = HealthRegistry(
[
AppAliveCheck(),
health_check("database", lambda: "connection ok"),
health_check("redis", lambda: "cache reachable"),
]
)
install_health_check(app, registry)
This exposes GET /ht.
- In a browser, the route renders an HTML health page
- For automated integrations, the same route returns JSON when the client sends
Accept: application/json
Monitoring custom areas
If you want to monitor anything beyond the built-in app liveness check, the easiest option is the health_check() factory.
You can use it for:
- databases
- Redis or cache layers
- background queues
- external APIs
- storage services
- internal domain-specific dependencies
Synchronous checks
from fastapi_health_check import health_check
database_check = health_check("database", lambda: "connection ok")
redis_check = health_check("redis", lambda: "cache reachable")
Asynchronous checks
from fastapi_health_check import health_check
async def payments_api_check() -> str | None:
return "payments API available"
payments_check = health_check("payments_api", payments_api_check)
Class-based checks for advanced cases
from fastapi_health_check import HealthCheck
class QueueCheck(HealthCheck):
default_name = "queue"
async def check(self) -> str | None:
return "queue connected"
Use class-based checks when you want:
- dependency injection through
__init__ - reusable state
- more structured custom behavior
Local manual testing
The repository includes a local example application at src/examples/basic_app.py.
Run it with:
uv run uvicorn src.examples.basic_app:app --reload
Then open:
http://127.0.0.1:8000/htfor the HTML pagecurl -H "Accept: application/json" http://127.0.0.1:8000/htfor JSON
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_ht-0.1.1.tar.gz.
File metadata
- Download URL: fastapi_ht-0.1.1.tar.gz
- Upload date:
- Size: 885.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a79d07a3faaa5c15c429eedfc8321a0fdbb303e4d379adedc008992e3d49f0b
|
|
| MD5 |
044bc72a6e514454c8e1d81f2e50fffd
|
|
| BLAKE2b-256 |
8cd9dcc8a74fb959c5f4917023492760906a3c66ab6fa69b751fd556a8b614a4
|
Provenance
The following attestation bundles were made for fastapi_ht-0.1.1.tar.gz:
Publisher:
publish.yml on PinnLabs/fastapi-health-check
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastapi_ht-0.1.1.tar.gz -
Subject digest:
4a79d07a3faaa5c15c429eedfc8321a0fdbb303e4d379adedc008992e3d49f0b - Sigstore transparency entry: 1452436061
- Sigstore integration time:
-
Permalink:
PinnLabs/fastapi-health-check@d6f86ff72e210dc281bfb9de7d9162c38e02e295 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/PinnLabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d6f86ff72e210dc281bfb9de7d9162c38e02e295 -
Trigger Event:
release
-
Statement type:
File details
Details for the file fastapi_ht-0.1.1-py3-none-any.whl.
File metadata
- Download URL: fastapi_ht-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ae6ebebc92944bd585718f3987e688eccb91a0dceccf44119e018e9183e81a7
|
|
| MD5 |
966da61ecb4f84268634aed619b42157
|
|
| BLAKE2b-256 |
792319eb5336ce6b98320c188070b434f81dec9e7ea89c241cb0535a35954d7b
|
Provenance
The following attestation bundles were made for fastapi_ht-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on PinnLabs/fastapi-health-check
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastapi_ht-0.1.1-py3-none-any.whl -
Subject digest:
2ae6ebebc92944bd585718f3987e688eccb91a0dceccf44119e018e9183e81a7 - Sigstore transparency entry: 1452436130
- Sigstore integration time:
-
Permalink:
PinnLabs/fastapi-health-check@d6f86ff72e210dc281bfb9de7d9162c38e02e295 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/PinnLabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d6f86ff72e210dc281bfb9de7d9162c38e02e295 -
Trigger Event:
release
-
Statement type: