fastapi-neo4j-healthcheck 🚀
Production-grade, zero-overhead Neo4j health check endpoint for FastAPI applications with Kubernetes liveness/readiness probe support.
Features
- ⚡ Sync & Async Driver Support: Seamlessly works with
neo4j.AsyncGraphDatabaseandneo4j.GraphDatabase. - 🩺 Non-Blocking Ping: Executes lightweight Cypher queries (
RETURN 1 AS ping) off the main thread or via async I/O. - ⏱️ Timeout Protection: Configurable timeout (default
3.0s) to prevent health check hangs during database failover or high load. - ⚓ Kubernetes Ready: Returns
200 OKwhen healthy and503 Service Unavailable(customizable) when degraded. - 📊 Observability & Latency: Includes latency in milliseconds (
latency_ms) and database target details in the response payload.
Installation
pip install fastapi-neo4j-healthcheck
Or with neo4j driver included:
pip install fastapi-neo4j-healthcheck[neo4j]
Quickstart
1. Using Async Neo4j Driver (Recommended)
from fastapi import FastAPI
from neo4j import AsyncGraphDatabase
from fastapi_neo4j_healthcheck import create_neo4j_health_router
app = FastAPI(title="Graph API")
# Initialize Neo4j Async Driver
driver = AsyncGraphDatabase.driver("bolt://localhost:7687", auth=("neo4j", "password"))
# Include Health Check Router
app.include_router(
create_neo4j_health_router(
driver_provider=driver,
prefix="/health/neo4j",
tags=["Health"],
)
)
2. Using Sync Neo4j Driver
from fastapi import FastAPI
from neo4j import GraphDatabase
from fastapi_neo4j_healthcheck import create_neo4j_health_router
app = FastAPI()
driver = GraphDatabase.driver("bolt://localhost:7687", auth=("neo4j", "password"))
app.include_router(
create_neo4j_health_router(driver_provider=driver, prefix="/healthcheck")
)
3. Dynamic / Dependency-Injected Driver Provider
from fastapi import FastAPI
from fastapi_neo4j_healthcheck import create_neo4j_health_router
def get_db_driver():
return current_app_state.neo4j_driver
app = FastAPI()
app.include_router(
create_neo4j_health_router(driver_provider=get_db_driver)
)
Response Schema
Healthy (HTTP 200)
{
"status": "healthy",
"database": "neo4j",
"latency_ms": 3.45,
"details": {
"connected": true
}
}
Unhealthy (HTTP 503)
{
"status": "unhealthy",
"database": "neo4j",
"latency_ms": 3001.12,
"details": {
"connected": false,
"error": "ServiceUnavailable: Could not perform discovery for database 'neo4j'"
}
}
Kubernetes Readiness Probe Configuration
livenessProbe:
httpGet:
path: /health/neo4j
port: 8000
initialDelaySeconds: 5
periodSeconds: 10
readinessProbe:
httpGet:
path: /health/neo4j
port: 8000
initialDelaySeconds: 2
periodSeconds: 5
License
MIT License - Created by Gabaoun.
Metadata
Release files for fastapi-neo4j-healthcheck 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fastapi_neo4j_healthcheck-0.1.0.tar.gz | 4.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fastapi_neo4j_healthcheck-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.3 kB
Release files / fastapi_neo4j_healthcheck-0.1.0.tar.gz
| Download URL | fastapi_neo4j_healthcheck-0.1.0.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6aa19a82c4ecef1e026b16d93ea7090ed848ccfd512bd7e71f7385ad1a654a6e
|
|
BLAKE2b-256 checksum How to use checksums |
a89e5984f456ae1f4a2abcde85c83894d081178368765ec5fbe0fb227f04a575
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 13, 2026.
Transparency logRelease files / fastapi_neo4j_healthcheck-0.1.0-py3-none-any.whl
| Download URL | fastapi_neo4j_healthcheck-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b1b8c5915a7f86194a34fb9498f7dacf3fdd9636d09f8311f78092151c5dc17c
|
|
BLAKE2b-256 checksum How to use checksums |
28324d105ee100188b2cef2dcbace31768d925377e55aa30a9231f9f992d745d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 13, 2026.
Transparency log