Developer API

Build with the HeartAfrika API

RESTful API for cardiac risk assessment, food recognition, health tracking, medication management, and PDF report generation. Built for African health applications.

Use Cases

What You Can Build

Our API gives you access to the same AI models that power HeartAfrika. Integrate into hospital systems, mobile apps, wellness platforms, and research projects across Africa.

Hospital & EMR Integration

Embed cardiac risk scoring into Electronic Medical Records. Submit patient vitals (age, BP, cholesterol, BMI, HbA1c, etc.) and receive instant risk scores and categories.

Mobile Health Apps

Add heart risk assessment, food recognition (AI-powered image analysis), and health tracking to any mobile or web health application.

Corporate Wellness Programs

Offer employees heart health screening via bulk assessments. Export assessment data as CSV for HR reporting and wellness analytics.

Health Research

Use our cardiovascular risk models built for African populations. Access health summary analytics and assessment trend data via API.

WhatsApp Bot Integration

Connect your own WhatsApp bot to our assessment engine via the webhook endpoint. Users complete assessments entirely within WhatsApp.

assessment.py
import requests

# Create a cardiac risk assessment
response = requests.post(
    "https://heartafrika.xyz/cardio/api/v1/assessments",
    headers={
        "X-API-Key": "YOUR_API_KEY",
        "Content-Type": "application/json"
    },
    json={
        "age": 45,
        "sex": "male",
        "systolic_bp": 135,
        "diastolic_bp": 85,
        "pulse_rate": 72,
        "respiratory_rate": 16,
        "height": 175,
        "weight": 82,
        "cholesterol": 220,
        "smoker": False,
        "diabetic": False,
        "family_history": True
    }
)

result = response.json()
# {
#   "assessment": {
#     "risk_score": 32.4,
#     "risk_category": "moderate",
#     "bmi": 26.8,
#     ...
#   }
# }
Endpoints

API Reference

All endpoints use base URL https://heartafrika.xyz/cardio/api/v1 and require an X-API-Key header.

POST

/assessments

Submit vitals (age, sex, BP, cholesterol, BMI, HbA1c, lifestyle) and receive a risk score + category.

GET

/assessments

List all assessments for the authenticated user with pagination (limit & offset).

GET

/assessments/export

Export all assessment data as CSV for reporting and analytics.

POST

/food/recognize

Upload a food image for AI-powered recognition with nutritional information and heart-health score.

GET

/food/database

Search the Nigerian food database by name. Returns calories, protein, carbs, fat, and heart-healthy flag.

GET

/health-summary

Aggregated health summary: food logs, activity entries, heart-healthy eating ratio, and trends.

GET

/reports/pdf/{id}

Generate and download a detailed PDF cardiac risk report for any assessment.

POST

/medications

Create medication reminders with dosage, frequency, and stock tracking. Mark taken or skipped.

GET

/recommendations

AI-generated health recommendations based on assessment results. Track read and completion status.

Pricing

API Plans

All plans include API key management, usage stats, and the full endpoint suite. Upgrade anytime from your dashboard.

Free

₦0/month
  • 10 API requests/month
  • Basic risk assessment
  • JSON responses
  • One-time assessment limit per user
  • AI recommendations
  • PDF report generation
Get Free Key

Enterprise

₦50,000/month
  • 10,000 API requests/month
  • Everything in Professional
  • Bulk analysis endpoint
  • White-label configuration
  • WhatsApp webhook integration
  • Dedicated account manager
Contact Sales
Authentication

Simple API Key Auth

Generate API keys from your HeartAfrika dashboard. Include your key in every request header. Keys are scoped to your plan with automatic rate limiting.

  • Generate multiple API keys per account
  • Revoke keys instantly from your dashboard
  • Real-time usage stats & downloadable reports
  • Automatic plan-based rate limiting
  • Plan upgrade alerts when approaching limits
  • CORS enabled for browser-based apps
auth_example.sh
# Authenticate with API Key header
curl -X POST \
  https://heartafrika.xyz/cardio/api/v1/assessments \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "age": 52,
    "sex": "female",
    "systolic_bp": 140,
    "diastolic_bp": 90,
    "pulse_rate": 78,
    "respiratory_rate": 18,
    "height": 165,
    "weight": 74,
    "cholesterol": 240
  }'

# Check your API usage
curl https://heartafrika.xyz/cardio/api/v1/api-usage \
  -H "X-API-Key: YOUR_API_KEY"

Ready to Integrate?

Sign up for a free account, generate your API key, and start building in minutes.