Cardiovascular Diseases API

API Endpoint

POST /predict

Accepts patient health features and returns risk of cardiovascular disease.

Request Format

Send a JSON payload with these features:

{
    "Age": 60,
    "Sex": "M",
    "ChestPainType": "ASY",
    "RestingBP": 160,
    "Cholesterol": 0,
    "FastingBS": 1,
    "RestingECG": "Normal",
    "MaxHR": 149,
    "ExerciseAngina": "N",
    "Oldpeak": 0.4,
    "ST_Slope": "Flat"
}

The API expects the features inside a "features" key:

{
    "features": {
        "Age": 60,
        "Sex": "M",
        "ChestPainType": "ASY",
        "RestingBP": 160,
        "Cholesterol": 0,
        "FastingBS": 1,
        "RestingECG": "Normal",
        "MaxHR": 149,
        "ExerciseAngina": "N",
        "Oldpeak": 0.4,
        "ST_Slope": "Flat"
    }
}

Python Example

import requests

API_URL = "https://cardiovascular-diseases-api-761922006747.us-east1.run.app/predict"
# API_URL = "http://localhost:8080/predict"

sample_input = {
    "Age": 60,
    "Sex": "M",
    "ChestPainType": "ASY",
    "RestingBP": 160,
    "Cholesterol": 0,
    "FastingBS": 1,
    "RestingECG": "Normal",
    "MaxHR": 149,
    "ExerciseAngina": "N",
    "Oldpeak": 0.4,
    "ST_Slope": "Flat"
}

request_data = {"features": sample_input}

response = requests.post(API_URL, json=request_data)

print(f"Status code: {response.status_code}")
print("Prediction:", response.json())

cURL Example

curl -X POST "https://cardiovascular-diseases-api-761922006747.us-east1.run.app/predict" \
-H "Content-Type: application/json" \
-d '{
  "features": {
    "Age": 60,
    "Sex": "M",
    "ChestPainType": "ASY",
    "RestingBP": 160,
    "Cholesterol": 0,
    "FastingBS": 1,
    "RestingECG": "Normal",
    "MaxHR": 149,
    "ExerciseAngina": "N",
    "Oldpeak": 0.4,
    "ST_Slope": "Flat"
  }
}'

Expected Response

{
  "prediction": "0|1"
}
Try it in Interactive Docs

Feature Descriptions

Feature Name Description Typical Range Type
AgeAge of the patient [years]> 0Integer
SexSex of the patient [M: Male, F: Female]M / FCategorical
ChestPainTypeChest pain typeTA / ATA / NAP / ASYCategorical
RestingBPResting blood pressure [mm Hg]~ 90–200Integer
CholesterolSerum cholesterol [mg/dl]~ 0–600Integer
FastingBSFasting blood sugar >120 mg/dl0 or 1Integer
RestingECGResting electrocardiogram resultsNormal / ST / LVHCategorical
MaxHRMaximum heart rate achieved60–202Integer
ExerciseAnginaExercise-induced anginaY / NCategorical
OldpeakST depression induced by exercise>= 0Float
ST_SlopeSlope of the peak exercise ST segmentUp / Flat / DownCategorical
HeartDiseaseTarget variable0 = Normal, 1 = Heart diseaseBinary