Deep Dive June 6, 2026 · 13 min read

Body Fat Percentage API — Calculate Body Fat via Mobile Camera (2026)

How AI body fat APIs work, how accurate they are compared to DEXA and calipers, a full breakdown of the API response schema, and a working integration example.

verified Published by the WorkoutX team — builders of the exercise API used by fitness app developers. Learn more

Body Fat Percentage API Cover Image - WorkoutX Blog
bolt Quick Summary (TL;DR)

Understand the science and engineering behind estimating body fat percentages using standard mobile camera photos. Includes a step-by-step REST API response breakdown and a working Python script for client-side integration.

Body Fat % via Camera vs Traditional Methods

Body fat percentage is the single most meaningful metric in fitness tracking — more informative than weight alone, more actionable than BMI. Yet for decades, measuring it accurately required either an expensive lab visit (DEXA, hydrostatic weighing) or an error-prone technique (calipers, BIA scales). The result: most fitness apps simply ask users to type in a number they don't actually know.

AI body fat APIs change this. By submitting a front-facing photo and basic biometrics, an app can return a body fat percentage estimate in under two seconds — with accuracy comparable to consumer-grade BIA scales, and far better than a self-reported guess.

Analysis method
AI
formula ensemble + vision
Response time
<1.2s
median latency
Hardware required
None
any smartphone camera

How AI Calculates Body Fat From a Single Photo

Camera-based body fat estimation is not a single model — it's a layered pipeline:

Stage 1 — Pose detection & landmark extraction

A pose estimation model (MediaPipe Pose or equivalent) identifies 33 skeletal landmarks in the image: joints, limb endpoints, facial keypoints, and torso reference points. This produces a 2D skeleton overlay that maps to pixel coordinates.

Stage 2 — Digital anthropometry

Using the landmark positions and the supplied height, the pipeline calculates a pixels-per-centimeter ratio. This ratio is used to estimate circumferences at standard measurement sites — waist, chest, hips, thighs, biceps, and more. This is the core of digital anthropometry: the automated application of the science of body measurement (anthropometry) using computer vision instead of a tape measure.

The accuracy of this step is highly dependent on photo quality — distance, pose, clothing, and lighting all affect how cleanly the landmarks are detected.

Stage 3 — Formula ensemble

Multiple validated body fat estimation formulas are applied simultaneously, each using the estimated measurements as inputs:

  • US Navy method: Uses waist, neck (for men) or waist, hips, neck (for women) circumferences
  • Deurenberg formula: Uses BMI, age, and sex
  • Gallagher formula: A BMI-based regression validated across ethnic groups
  • Jackson-Pollock adapted: Uses estimated skinfold-proxy circumferences

Results are averaged with weighting based on how well each formula's inputs were estimated from the image. The ensemble approach reduces the impact of any single formula's error mode.

Stage 4 — Vision model calibration

A vision language model performs a qualitative pass — assessing visible muscle definition, fat distribution pattern, and body type — and applies a calibration adjustment to the ensemble output. This stage adds nuance that pure formula approaches miss: the visual difference between a 20% body fat "skinny-fat" physique and a 20% body fat athletic physique is detectable visually even when circumference measurements are identical.

DEXA Correlation: How Accurate Is the API?

DEXA (Dual-Energy X-ray Absorptiometry) is the clinical gold standard for body composition measurement. The WorkoutX Body Scan API does not attempt to replace it — it estimates body composition from photos using published anthropometric formulas combined with computer vision, and reports a confidence score so you can judge each result. For clinical-grade measurement, DEXA remains the reference.

Method Avg error vs DEXA Hardware cost At-home possible API available
WorkoutX Camera API This Estimate None ✓ ✓ REST
DEXA Scan Reference (gold standard) $100–200/session ✗ Lab required ✗
BIA Scale (consumer) ±3–5% $30–$300 ✓ ✗ Rarely
Skinfold Calipers ±3–4% (trained tech) <$20 ✗ Technician needed ✗
Online BMI Calculator ±5–10% Free ✓ ✓
Hydrostatic Weighing ±1.5% Lab only ✗ ✗

Accuracy is highest for subjects with BMI 18–35 in standard lighting with form-fitting clothing. Accuracy degrades at BMI extremes (<17 or >42) and in poor photo conditions (dark lighting, loose clothing, extreme angles).

API Response Deep Dive

The full JSON response from POST /v1/analyze is grouped into these sections:

{
  "scan_id": "bscan_7xK9mP",

  // ── Body Composition ──────────────────────────
  "body_composition": {
    "body_fat_percentage": 14.6,        // Primary metric
    "body_fat_category": "Fitness",
    "body_fat_mass_kg": 9.9,
    "lean_mass_kg": 58.1,
    "body_type": "Ecto-Mesomorph",
    "bmi": 21.0,
    "bmi_category": "Normal",
    "body_fat_range": {                 // front-photo-only scans; omitted with a side photo
      "low": 13.1,
      "high": 16.1,
      "confidence": "medium"
    }
  },

  // ── Scores ────────────────────────────────────
  "scores": {
    "muscle_score": 53,                 // Visible muscle development (0–100)
    "symmetry_score": 99.0,             // Left/right balance
    "fitness_score": 80                 // Composite indicator
  },

  // ── Estimated Measurements (cm) ───────────────
  "estimated_measurements": {
    "shoulder_width_cm": 44.2,
    "waist_circumference_cm": 78.5,
    "hip_circumference_cm": 91.2,
    "waist_to_hip_ratio": 0.86
  },

  // ── AI Insights ───────────────────────────────
  "ai_insights": {
    "body_type_detail": "Athletic frame with good muscle-building potential.",
    "posture_notes": "Neutral posture, shoulders level.",
    "fat_distribution": "balanced",
    "muscle_definition_score": 7        // Visible definition (1–10)
  },

  "photo_guidance": null,               // set when clothing or pose issues are detected

  // ── Usage ─────────────────────────────────────
  "credits": {
    "used": 1,
    "remaining": 499
  }
}

Comparison: WorkoutX vs DEXA vs Calipers vs BIA

When evaluating which body fat measurement method to recommend to your users — or to integrate into your app — here is the complete trade-off picture:

Factor Camera API DEXA Calipers BIA Scale
Fat % accuracy Estimate ±1% (gold std.) ±3–4% ±3–5%
Circumference data 14 sites Body regions only Site-specific None
Posture analysis Yes No No No
No hardware needed Yes No Cheap device Scale required
App integrable via API Yes — REST No No Rarely
Cost per measurement $0.06–0.19 $100–200 ~$0 ~$0 (scale amortised)
Photo retention None (HIPAA-ready) Yes — medical record N/A N/A

Integration Example — Full Code

A complete body fat scanning flow in Python, from photo to displaying the result:

import requests
import json

SCAN_API_KEY = "bsk_your_key_here"
BASE_URL = "https://amused-mercy-production-aeaa.up.railway.app/v1"

def get_body_fat(photo_path, height_cm, weight_kg, age, gender):
    """Submit a scan and return the body fat percentage and key metrics."""
    with open(photo_path, "rb") as photo:
        response = requests.post(
            f"{BASE_URL}/analyze",
            headers={"X-BodyScan-Key": SCAN_API_KEY},
            files={"front_photo": photo},
            data={
                "height_cm": height_cm,
                "weight_kg": weight_kg,
                "age": age,
                "gender": gender,
            },
            timeout=15,
        )

    response.raise_for_status()
    scan = response.json()

    return {
        "body_fat_pct": scan["body_composition"]["body_fat_percentage"],
        "category":     scan["body_composition"]["body_fat_category"],
        "muscle_score": scan["scores"]["muscle_score"],
        "waist_cm":     scan["estimated_measurements"]["waist_circumference_cm"],
        "posture":      scan["ai_insights"]["posture_notes"],
        "credits_left": scan["credits"]["remaining"],
    }


# Usage
result = get_body_fat(
    photo_path="user_scan.jpg",
    height_cm=178,
    weight_kg=75,
    age=28,
    gender="male"
)

print(f"Body fat: {result['body_fat_pct']}% ({result['category']})")
print(f"Muscle score: {result['muscle_score']}/100")
print(f"Waist: {result['waist_cm']} cm")
print(f"Posture: {result['posture']}")
print(f"Credits remaining: {result['credits_left']}")

Start with 5 free scans, then a Starter pack — 20 scans for $39, no subscription. Enough to build and test a full integration end-to-end before committing to a larger credit pack. View pricing →

© 2026 WorkoutX. All rights reserved.

Base URL: https://api.workoutxapp.com