The goal of this package is to help you to implement the Health Check API pattern.
pip install fastapi-health
Using this package, you can create the health check endpoint dynamically using different conditions. Each condition is a callable and you can even have dependencies inside of it.
from fastapi import FastAPI, Depends
from fastapi_health import health
def get_session():
return True
def is_database_online(session: bool = Depends(get_session)):
return session
app = FastAPI()
app.add_api_route("/health", health([is_database_online]))
The /health
endpoint on the example can return two possible response status code:
- 200 (Ok): conditions are satisfied.
- 503 (Service Unavailable): at least one condition is false.
This project is licensed under the terms of the MIT license.