Metadata-Version: 2.4
Name: glucoguard
Version: 0.1.0
Summary: Python client for the GlucoGuard diabetes and cardiovascular risk prediction API
Author-email: Analytica Data Science Solutions <api@analyticadss.com>
License: MIT
Project-URL: Homepage, https://glucoguard.analyticadss.com
Project-URL: Documentation, https://glucoguard.analyticadss.com/docs
Project-URL: Repository, https://github.com/aousabdo/glucoguard
Keywords: glucoguard,health,diabetes,cvd,ml,api-client
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Healthcare Industry
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: requests>=2.28

# glucoguard — Python SDK

Tiny Python client for the GlucoGuard REST API.

## Install

```bash
pip install glucoguard
```

Or vendor it directly — the whole client is one file (`glucoguard/client.py`)
with only `requests` as a dependency.

## Quick start

```python
from glucoguard import GlucoGuard

gg = GlucoGuard(api_key="sk_live_...")

result = gg.predict_diabetes(
    age=55, gender=0, bmi=30,
    systolic_bp=140, diastolic_bp=88,
    hba1c=6.5,
)

print(f"Risk: {result.risk_score}% ({result.risk_category})")
for factor in result.top_factors[:3]:
    print(f"  {factor.feature}: {factor.direction} ({factor.shap_value:+.3f})")
```

## Batch predictions

```python
patients = [
    {"age": 55, "gender": 0, "bmi": 30, "systolic_bp": 140, "diastolic_bp": 88},
    {"age": 35, "gender": 1, "bmi": 22, "systolic_bp": 118, "diastolic_bp": 72},
]
batch = gg.predict_batch(patients)
print(f"Processed {batch.total} patients in {batch.processing_time_ms:.0f}ms")
```

## Webhook batch jobs

For long-running jobs, provide a webhook URL and GlucoGuard will POST
the results to your endpoint when the batch completes:

```python
job = gg.predict_batch(patients, webhook_url="https://your-server.com/glucoguard-hook")
print(job["job_id"], job["status"])  # "queued"
```

The webhook receives JSON with `{job_id, status, completed_at, result}`.
The `X-GlucoGuard-Job-Id` header is set on the delivery request.

## PDF reports

```python
from pathlib import Path

pdf_bytes = gg.generate_pdf_report(
    patient={"age": 55, "gender": 0, "bmi": 30, ...},
    diabetes_result={"risk_score": 52.3, "risk_category": "moderate", ...},
    cvd_result={"risk_score": 38.1, "risk_category": "low", ...},
    patient_name="Jane Smith",
)
Path("report.pdf").write_bytes(pdf_bytes)
```

## Error handling

Every failure raises `GlucoGuardError` with a `status_code` attribute.

```python
from glucoguard import GlucoGuard, GlucoGuardError

gg = GlucoGuard(api_key="sk_live_...")
try:
    result = gg.predict_diabetes(age=55, gender=0, bmi=30, systolic_bp=140, diastolic_bp=88)
except GlucoGuardError as exc:
    if exc.status_code == 401:
        print("Bad API key")
    elif exc.status_code == 429:
        print("Rate limited — back off and retry")
    else:
        print(f"API error: {exc}")
```

## Ops endpoints

```python
gg.health()          # liveness probe
gg.status()          # full status with model versions and uptime
gg.model_info("diabetes")
gg.sample_patients()
```

## Links

- API docs: https://glucoguard.analyticadss.com/docs
- Homepage: https://glucoguard.analyticadss.com
- Issues: mailto:api@analyticadss.com

Built by [Analytica Data Science Solutions](https://analyticadss.com).
