🏥 Health Calculator API

Comprehensive health calculations with BMI, BMR, Daily Intake, and Water Intake

📖 Overview

The Health Calculator API provides comprehensive health-related calculations including BMI (Body Mass Index), BMR (Basal Metabolic Rate), Daily Caloric Intake, and Water Intake requirements. All calculations are based on scientifically proven formulas and provide detailed recommendations.

🧮 BMI Calculator

Calculate Body Mass Index with WHO standard categories and health recommendations

🔥 BMR Calculator

Basal Metabolic Rate calculation using the accurate Mifflin-St Jeor equation

🍽️ Daily Intake Calculator

Personalized caloric needs with detailed macronutrient breakdown

💧 Water Intake Calculator

Daily water requirements based on multiple health and environmental factors

🌐 Base URL

https://api.lorwongam.com/api/health-calculator/

🔐 Authentication

No authentication required. This is a public API that can be accessed without any API keys or tokens.

📡 API Endpoints

GET / POST / Unified Health Calculator

The same endpoint handles all four calculators. Pass the calculator name in calculator; the other fields depend on which calculator you choose. Parameters may be supplied via the query string (GET) or as a JSON body (POST) — POSTed keys override query-string keys.

Common Parameters

Parameter Type Required Description
calculator string Required One of bmi, bmr, intake, water
unit string Optional metric (default) or imperial. For imperial, weight is treated as pounds and height as inches (only relevant for non-water calculators).

Calculator-Specific Parameters

Parameter Used by Required Description
weight all Required Weight in kg (or lb if unit=imperial)
height bmi, bmr, intake Required* Height in cm (or in if unit=imperial). Ignored for water.
age bmr, intake, water Required* Age in years (1–120)
gender bmr, intake, water Required* male or female
activity bmr, intake, water Required* sedentary, light, moderate, active, extra
goal intake Required maintain, lose, lose-fast, gain, gain-fast
climate water Required cold, temperate, hot, very-hot
healthCondition water Required normal, fever, diarrhea, kidney, heart, pregnancy, breastfeeding (note the camelCase spelling)

Example Request — BMI

curl "https://api.lorwongam.com/api/health-calculator/?calculator=bmi&weight=70&height=175"

Example Request — BMR (POST JSON)

curl -X POST "https://api.lorwongam.com/api/health-calculator/" \ -H "Content-Type: application/json" \ -d '{ "calculator": "bmr", "weight": 70, "height": 175, "age": 30, "gender": "male", "activity": "moderate" }'

Example Request — Daily Intake

curl "https://api.lorwongam.com/api/health-calculator/?calculator=intake&weight=70&height=175&age=30&gender=male&activity=moderate&goal=maintain"

Example Request — Water Intake

curl "https://api.lorwongam.com/api/health-calculator/?calculator=water&weight=70&age=30&gender=male&activity=moderate&climate=temperate&healthCondition=normal"

📊 Response Format

Success Response — BMI

{ "success": true, "data": { "bmi": 22.86, "category": "Normal weight", "advice": "Great! Maintain your current lifestyle with a balanced diet and regular exercise." }, "calculator": "bmi", "timestamp": "2025-09-09 12:00:00" }

Success Response — BMR

{ "success": true, "data": { "bmr": 1649, "detail": "Daily calories needed: 2556", "advice": "Your BMR is 1649 calories per day. With your activity level, you need approximately 2556 calories daily to maintain your current weight." }, "calculator": "bmr", "timestamp": "2025-09-09 12:00:00" }

Success Response — Daily Intake

{ "success": true, "data": { "calories": 2556, "breakdown": "Protein: 112g • Carbs: 367g • Fat: 71g
BMR: 1649 cal • Maintenance: 2556 cal", "advice": "To maintain your current weight, aim for 2556 calories per day with balanced nutrition and regular exercise.", "macros": { "protein": 112, "carbs": 367, "fat": 71 } }, "calculator": "intake", "timestamp": "2025-09-09 12:00:00" }

Success Response — Water Intake

{ "success": true, "data": { "amount": "3773ml/day", "breakdown": "Total: 3773ml • From drinks: 3018ml • From food: 755ml
Approximately 12.1 glasses (250ml each)", "advice": "Aim for approximately 3773ml (12.1 glasses) of water daily. Spread intake throughout the day...", "details": { "total": 3773, "fromDrinks": 3018, "fromFood": 755, "glasses": 12.1 } }, "calculator": "water", "timestamp": "2025-09-09 12:00:00" }

Error Responses

All error responses are JSON with HTTP 400 (or 404 in rare routing edge cases). The shape varies by trigger:

Calculator type missing

{ "success": false, "message": "Calculator type is required", "availableCalculators": ["bmi", "bmr", "intake", "water"] }

Missing required field(s) — message is a comma-joined list, errors is the same list as an array

{ "success": false, "message": "Height is required for bmr calculation, Age is required for bmr calculation, ...", "errors": ["Height is required for bmr calculation", "Age is required for bmr calculation", "..."] }

Invalid value (out of range / unrealistic)

{ "success": false, "message": "Please check your height and weight values - they seem unrealistic" }

⚠️ Error Conditions

The API does not return a numeric code field. Errors are identified by the human-readable message string.

Trigger HTTP Notes
Missing calculator 400 Returns availableCalculators to help clients pick
One or more required fields missing for the chosen calculator 400 Returns comma-joined message and parallel errors array
Age out of range (must be 1–120) 400 message: "Age must be between 1 and 120 years"
Unrealistic weight / height 400 message: "Please check your height and weight values - they seem unrealistic" (for water: "Please check your weight value - it seems unrealistic")
Negative or zero weight / height (bmi, bmr, intake) 400 message: "Weight and height must be positive values"
Negative or zero weight (water) 400 message: "Weight must be a positive value"

🚦 Rate Limits

This endpoint is rate-limited per client identity (IP address, or API key when one is supplied): 60 requests per minute. When the budget is exhausted the API responds with HTTP 429 and includes X-RateLimit-* headers so clients can self-throttle. The exact policy is configured in api/includes/api_config.php.

🎯 Ready to Try?

Test the Health Calculator API with our interactive web interface or start integrating it into your application.

Try Web Interface Test API Endpoint