Skip to main content
GET
/
health
Health Check
curl --request GET \
  --url https://api.example.com/health
{
  "ready": true,
  "predictor_loaded": true,
  "drift_baseline_loaded": true
}

Health Check Endpoint

Checks the readiness status of the Student Purchase Prediction API and its components.

Endpoint

GET /health

Response

Returns the health status of the API service and its loaded artifacts.
ready
boolean
required
Overall readiness status. Returns true only when model, threshold, and feature config are all loaded.
predictor_loaded
boolean
required
Whether the trained model artifact has been successfully loaded into memory.
drift_baseline_loaded
boolean
required
Whether the drift monitoring baseline file has been loaded. Used for distribution drift detection.

Status Codes

  • 200 OK - Health check completed successfully

Example Request

cURL
curl -X GET "http://localhost:8000/health" \
  -H "accept: application/json"

Example Response

200 OK
{
  "ready": true,
  "predictor_loaded": true,
  "drift_baseline_loaded": true
}

Service Not Ready

200 OK
{
  "ready": false,
  "predictor_loaded": false,
  "drift_baseline_loaded": false
}

Implementation Details

Defined in src/api.py:275-281 Response Model: HealthResponse (src/api.py:50-53)
class HealthResponse(BaseModel):
    ready: bool
    predictor_loaded: bool
    drift_baseline_loaded: bool
The endpoint checks global state variables:
  • _MODEL: Trained scikit-learn model
  • _THRESHOLD: Classification threshold
  • _FEATURE_CFG: Feature engineering configuration
  • _DRIFT_BASELINE: Baseline statistics for drift monitoring

Use Cases

  • Container health probes - Kubernetes liveness/readiness checks
  • Load balancer health checks - Ensure traffic only routes to ready instances
  • Monitoring dashboards - Track service availability
  • Pre-deployment validation - Verify artifacts loaded correctly after deployment

Build docs developers (and LLMs) love