# BMR & Calorie API
> Energy-expenditure and nutrition maths as an API, computed locally and deterministically. The bmr endpoint computes the basal metabolic rate — the calories the body burns at rest — from weight, height, age and sex, using the modern Mifflin-St Jeor equation (BMR = 10·kg + 6.25·cm − 5·age + 5 for men, −161 for women) and reporting the classic revised Harris-Benedict value alongside for comparison. The tdee endpoint computes the total daily energy expenditure, TDEE = BMR × an activity factor from sedentary (1.2) to very active (1.9), and the goal calories for maintenance, mild and standard weight loss and weight gain — a 500 kcal/day deficit or surplus is about 0.45 kg per week. The macros endpoint splits a calorie target into protein, fat and carbohydrate grams, with protein set per kilogram of bodyweight (4 kcal/g protein and carbs, 9 kcal/g fat). Everything is computed locally and deterministically, so it is instant and private. Ideal for fitness, nutrition and health-app developers, diet and meal-planning tools, gym and coaching apps, and wellness dashboards. Pure local computation — no key, no third-party service, instant. Live, nothing stored. Estimates only, not medical advice. 3 endpoints. This is metabolic-rate and calorie maths; for body-mass-index use a BMI calculator.

## Authentication
All requests require your oanor API key in the `x-oanor-key` header. Get one at https://www.oanor.com/developer/keys.

```bash
curl -H "x-oanor-key: oanor_live_…" "https://api.oanor.com/bmr-api/..."
```

## Pricing
- **Free** (Free) — 3,000 calls/Mo, 2 req/s
- **Starter** ($4/Mo) — 40,000 calls/Mo, 5 req/s
- **Pro** ($11/Mo) — 250,000 calls/Mo, 15 req/s
- **Mega** ($39/Mo) — 1,500,000 calls/Mo, 40 req/s

## Endpoints

### BMR

#### `GET /v1/bmr` — Basal metabolic rate

**Parameters:**
- `weight` (query, required, string) — Weight (kg) Example: `80`
- `height` (query, required, string) — Height (cm) Example: `180`
- `age` (query, required, string) — Age (years) Example: `30`
- `sex` (query, required, string) — male | female Example: `male`
- `formula` (query, optional, string) — mifflin | harris (default mifflin) Example: `mifflin`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/bmr-api/v1/bmr?weight=80&height=180&age=30&sex=male&formula=mifflin"
```

**Response:**
```json
{
    "data": {
        "note": "BMR is resting energy. Mifflin-St Jeor is the modern default; Harris-Benedict is the classic revised form.",
        "inputs": {
            "age": 30,
            "sex": "male",
            "height": 180,
            "weight": 80,
            "formula": "mifflin"
        },
        "bmr_kcal_day": 1780,
        "harris_kcal_day": 1853.63,
        "mifflin_kcal_day": 1780
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:22.031Z",
        "request_id": "99bfda17-2f61-48ae-910d-37966baca2d1"
    },
    "status": "ok",
    "message": "Basal metabolic rate",
    "success": true
}
```

#### `GET /v1/macros` — Macronutrient split

**Parameters:**
- `calories` (query, required, string) — Calorie target (kcal) Example: `2500`
- `weight` (query, optional, string) — Bodyweight (kg) for protein per kg Example: `80`
- `protein_per_kg` (query, optional, string) — Protein g per kg (default 2.0) Example: `2.0`
- `fat_percent` (query, optional, string) — Fat as % of calories (default 25) Example: `25`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/bmr-api/v1/macros?calories=2500&weight=80&protein_per_kg=2.0&fat_percent=25"
```

**Response:**
```json
{
    "data": {
        "note": "Protein and carbs are 4 kcal/g, fat is 9 kcal/g. Protein from g/kg when a weight is given, otherwise 30 % of calories.",
        "fat_g": 69.4,
        "inputs": {
            "weight": 80,
            "calories": 2500,
            "fat_percent": 25,
            "protein_per_kg": 2
        },
        "carbs_g": 308.8,
        "fat_kcal": 625,
        "carb_kcal": 1235,
        "protein_g": 160,
        "protein_kcal": 640
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:22.137Z",
        "request_id": "a6bd798b-6b2b-4ca7-8a0a-cee1513c459f"
    },
    "status": "ok",
    "message": "Macronutrient split",
    "success": true
}
```

#### `GET /v1/tdee` — Total daily energy

**Parameters:**
- `bmr` (query, optional, string) — BMR (kcal/day) Example: `1780`
- `weight` (query, optional, string) — Or weight (kg) Example: `80`
- `height` (query, optional, string) — height (cm) Example: `180`
- `age` (query, optional, string) — age (years) Example: `30`
- `sex` (query, optional, string) — male | female Example: `male`
- `activity_level` (query, optional, string) — sedentary | light | moderate | active | very_active Example: `moderate`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/bmr-api/v1/tdee?bmr=1780&weight=80&height=180&age=30&sex=male&activity_level=moderate"
```

**Response:**
```json
{
    "data": {
        "note": "TDEE = BMR × activity factor. A ~500 kcal/day deficit or surplus is roughly 0.45 kg per week.",
        "inputs": {
            "bmr": 1780,
            "activity_level": "moderate",
            "activity_factor": 1.55
        },
        "tdee_kcal_day": 2759,
        "mild_loss_kcal": 2509,
        "maintenance_kcal": 2759,
        "weight_gain_kcal": 3259,
        "weight_loss_kcal": 2259
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:22.253Z",
        "request_id": "9a862609-41ad-41a7-87f2-bfaae208dc84"
    },
    "status": "ok",
    "message": "Total daily energy",
    "success": true
}
```

### Meta

#### `GET /v1/meta` — Spec

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/bmr-api/v1/meta"
```

**Response:**
```json
{
    "data": {
        "notes": "Weight in kg, height in cm, age in years. Activity: sedentary 1.2, light 1.375, moderate 1.55, active 1.725, very_active 1.9. Estimates only — not medical advice.",
        "service": "bmr-api",
        "formulae": {
            "tdee": "TDEE = BMR × activity factor (1.2–1.9)",
            "macros": "protein/carb 4 kcal/g, fat 9 kcal/g",
            "mifflin": "BMR = 10·kg + 6.25·cm − 5·age + (male:+5 / female:−161)"
        },
        "endpoints": {
            "GET /v1/bmr": "Basal metabolic rate from weight, height, age and sex (both formulae).",
            "GET /v1/meta": "This document.",
            "GET /v1/tdee": "Total daily energy expenditure and goal calories from BMR (or body data) and activity level.",
            "GET /v1/macros": "Protein/fat/carb split (grams and kcal) from a calorie target."
        },
        "description": "Energy-expenditure calculator: basal metabolic rate (Mifflin-St Jeor and Harris-Benedict), total daily energy expenditure and macronutrient split."
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:22.369Z",
        "request_id": "cd93fc03-6aa5-4477-a432-123608e63d59"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


---
Marketplace page: https://www.oanor.com/api/bmr-api
OpenAPI spec: https://www.oanor.com/api/bmr-api/openapi.json
