Body Composition API for Fitness Apps — Complete Developer Guide (2026)
Everything you need to integrate camera-based body composition analysis into your fitness app. From how the AI works to production-ready code in JavaScript, Python, and Swift.
verified Published by the WorkoutX team — builders of the exercise API used by fitness app developers. Learn more
A technical deep dive into integrating body composition telemetry into digital fitness platforms. Compare camera-based estimation APIs with commercial DEXA scans and 3D hardware scanners, and review key API request/response structures.
What Is a Body Composition API?
A body composition API is a REST service that accepts a photo alongside basic biometrics — height, weight, age, gender — and returns a structured JSON payload describing the subject's body in clinical terms: fat percentage, lean mass, muscle score, body type classification, posture flags, and circumference estimates.
Before camera-based body composition analysis existed, the only ways to measure body composition were expensive or inconvenient: DEXA scans in a radiology lab, hydrostatic weighing, bioelectrical impedance scales, or manual tape measurements by a fitness professional. A body composition API brings that analysis to any smartphone camera, making it practical at consumer scale.
Key insight: Body composition analysis is the most-requested feature addition among fitness app developers in 2026 — and it's now a single REST call away, with no ML infrastructure to manage.
How Camera-Based Body Scanning Works
Modern body composition APIs use a multi-stage computer vision and statistical pipeline:
- Pose estimation: A model (typically MediaPipe Pose or a fine-tuned equivalent) identifies 33+ skeletal landmarks — joints, limb endpoints, and torso reference points — from the 2D image.
- Anthropometric estimation: Landmark positions are combined with supplied height to calculate pixel-per-centimeter ratios, yielding circumference estimates for waist, hips, chest, thighs, arms, and more.
- Body fat formula ensemble: Multiple validated formulas (Deurenberg, Gallagher, US Navy method) are applied in parallel using the estimated measurements and supplied biometrics. Results are averaged and calibrated against a reference dataset.
- LLM vision pass: A vision model provides qualitative assessment — body type, fat distribution pattern, posture notes, and muscle definition score — adding nuance beyond pure formula outputs.
The combined pipeline ensembles multiple published anthropometric formulas so no single one dominates, and returns a confidence score alongside every estimate. Results are calibrated estimates for fitness tracking, not clinical measurements.
Key Metrics: What You Get Back
A full POST /v1/analyze response includes:
- Body composition (
body_composition):body_fat_percentage,body_fat_category,body_fat_mass_kg,lean_mass_kg,body_type,bmi,bmi_category - Body type: Ecto / Meso / Endomorph classification, plus a text description in
ai_insights.body_type_detail - Scores (
scores):muscle_score(0–100),symmetry_score,fitness_score - Measurements (
estimated_measurements):shoulder_width_cm,waist_circumference_cm,hip_circumference_cm,waist_to_hip_ratio - AI insights (
ai_insights):posture_notes,fat_distributionpattern,muscle_definition_score
REST API Integration
The WorkoutX Body Scan API accepts multipart/form-data POST requests to https://amused-mercy-production-aeaa.up.railway.app/v1/analyze. Authentication uses a single header: X-BodyScan-Key, with the bsk_ key from your dashboard.
cURL
curl -X POST https://amused-mercy-production-aeaa.up.railway.app/v1/analyze \ -H "X-BodyScan-Key: bsk_your_key_here" \ -F "front_photo=@front_photo.jpg" \ -F "height_cm=178" \ -F "weight_kg=75" \ -F "age=28" \ -F "gender=male"
JavaScript (fetch)
const form = new FormData();
form.append('front_photo', photoFile); // File object from <input type="file"> or camera capture
form.append('height_cm', 178);
form.append('weight_kg', 75);
form.append('age', 28);
form.append('gender', 'male');
const res = await fetch('https://amused-mercy-production-aeaa.up.railway.app/v1/analyze', {
method: 'POST',
headers: { 'X-BodyScan-Key': 'bsk_your_key_here' },
body: form
});
const scan = await res.json();
console.log(`Body fat: ${scan.body_composition.body_fat_percentage}%`);
console.log(`Muscle score: ${scan.scores.muscle_score}/100`);
Python
import requests
url = "https://amused-mercy-production-aeaa.up.railway.app/v1/analyze"
headers = {"X-BodyScan-Key": "bsk_your_key_here"}
with open("front_photo.jpg", "rb") as f:
res = requests.post(url, headers=headers, files={
"front_photo": f
}, data={
"height_cm": 178,
"weight_kg": 75,
"age": 28,
"gender": "male"
})
scan = res.json()
print(f"Body fat: {scan['body_composition']['body_fat_percentage']}%")
print(f"Waist: {scan['estimated_measurements']['waist_circumference_cm']} cm")
The API returns HTTP 200 on success. On failure it returns a JSON body with error and message: 400 for a missing photo or invalid fields, 401 for a missing or invalid key, and 402 when the account has no scan credits left.
Comparison: Camera API vs DEXA vs 3D Scanner
Understanding the trade-offs between body composition measurement methods is essential for choosing the right approach for your app.
| Method | Accuracy (Fat %) | Hardware cost | User convenience | API available | Best for |
|---|---|---|---|---|---|
| Camera API This | ±2–3% | None | Any smartphone | Yes — REST | Consumer fitness apps |
| DEXA Scan | ±1–2% | $100–$200/session | Lab visit required | No | Clinical / research |
| 3D Body Scanner | ±1–2% | $10,000–$50,000 | Dedicated hardware | Proprietary only | Gyms, clinics |
| BIA Scale | ±3–5% | $30–$300 | Good (home) | Rarely | Home tracking |
| Calipers | ±3–4% | <$20 | Requires technician | No | Personal trainers |
Use Cases Across Fitness Verticals
Body composition APIs are being adopted across every fitness and health vertical:
Consumer Fitness Apps
Replace the manual "enter your body fat %" input with an AI-powered camera scan on onboarding. Show progress over time with side-by-side scan comparisons. Gamify improvement with muscle and fitness scores.
Personal Training Platforms
Enable trainers to conduct remote assessments. Automate the initial consultation body scan and generate a PDF report. Track client progress without requiring in-person measurements.
Telehealth & Digital Health
Augment weight management programs with body composition tracking. HIPAA-ready architecture (no photo retention) makes this deployable in clinical workflows. Combine with exercise API data for holistic wellness scoring.
Corporate Wellness
Run company-wide wellness challenges with body composition benchmarks. Private, no-hardware, accessible from any device — reducing the friction of traditional biometric screenings.
Getting Started with WorkoutX Body Scan API
Getting up and running takes three steps:
- Start with 5 free scans, then purchase a credit pack at workoutxapp.com/bodyscan.html. Packs start at $39 for 20 scans — no subscription required.
- Add a camera capture UI to your app. Best results come from a front-facing photo taken 2–3 metres from the camera in form-fitting clothing with even lighting.
- POST to
https://amused-mercy-production-aeaa.up.railway.app/v1/analyzewith theX-BodyScan-Keyheader, the photo (front_photo) and biometrics. Parse the JSON response and display the metrics to your users.
Most developers complete the full integration — including the UI — in under two hours. The API returns consistent JSON across all plans, so switching from the free scans to Starter to Growth requires no code changes.
Ready to integrate? The Body Scan API page has full documentation, pricing, and live code examples in cURL, JavaScript, Python, and Swift.