# TDEE & Macro Calculator (`chun_yung_lo/tdee-macro-calculator`) Actor

Calculate BMR, TDEE, a goal-based calorie target and daily and per-meal protein, carb and fat grams from age, sex, weight, height and activity level. Deterministic and instant.

- **URL**: https://apify.com/chun_yung_lo/tdee-macro-calculator.md
- **Developed by:** [Chun-Yung Yong Lo](https://apify.com/chun_yung_lo) (community)
- **Categories:** Agents, MCP servers, Other
- **Features:** Limited permissions, Single-tenant, Server interface
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 calculation completed

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/actors/store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## TDEE & Macro Calculator

Calculate your daily calorie needs and macro targets in one call. Give age, sex, weight, height and activity level and get BMR, TDEE, a goal-adjusted calorie target, protein/carb/fat grams per day and per meal, and BMI. Runs offline, is deterministic, and returns instantly.

### What it does

- BMR with the Mifflin-St Jeor equation: `10*kg + 6.25*cm - 5*age + 5` (male) or `- 161` (female).
- TDEE = BMR x activity multiplier (sedentary 1.2, light 1.375, moderate 1.55, active 1.725, veryActive 1.9).
- Goal: `lose` = 80% of TDEE, `maintain` = 100%, `gain` = 110%.
- Macro presets (share of calories, protein/carbs/fat): balanced 25/45/30, highProtein 35/35/30, lowCarb 30/20/50, keto 20/5/75. Protein and carbs are 4 kcal/g, fat 9 kcal/g.
- Calories and macros split equally across 1-8 meals.

It does not include a food database or recipe-level meal plans.

### Input example

```json
{"sex": "male", "ageYears": 30, "weightKg": 80, "heightCm": 180, "activityLevel": "moderate", "goal": "maintain", "dietType": "balanced", "mealsPerDay": 3}
```

Limits: age 15-100, weight 30-300 kg, height 100-250 cm, meals 1-8.

### Output example

```json
{"status": "ok", "sex": "male", "ageYears": 30.0, "weightKg": 80.0, "heightCm": 180.0, "activityLevel": "moderate", "goal": "maintain", "dietType": "balanced", "formula": "Mifflin-St Jeor", "bmr": 1780, "tdee": 2759, "targetCalories": 2759, "proteinGrams": 172.4, "carbsGrams": 310.4, "fatGrams": 92.0, "bmi": 24.7, "mealsPerDay": 3, "caloriesPerMeal": 920, "proteinPerMealGrams": 57.5, "carbsPerMealGrams": 103.5, "fatPerMealGrams": 30.7, "warning": null}
```

Every row has a `status` field (`ok` on success). If the target is below 1500 kcal (male) or 1200 kcal (female), `warning` explains it. Invalid input stops the run with a clear error message naming the field.

### Pricing

US$0.001 per calculation (one run = one calculation).

### For AI agents (MCP)

Call this Actor through Apify's MCP server with:

```json
{"sex": "female", "ageYears": 25, "weightKg": 60, "heightCm": 165, "activityLevel": "light", "goal": "lose", "dietType": "highProtein", "mealsPerDay": 4}
```

One call returns one row with a `status` of `ok` and costs US$0.001. Field names are stable camelCase. Check `warning` before presenting a low-calorie target to a user.

### Limits and disclaimer

Estimates only, not medical advice. Equations are population averages; consult a qualified professional for medical conditions, pregnancy, or adolescents.

### Credits

Uses the Mifflin-St Jeor equation (Mifflin et al., 1990), a published scientific formula, implemented from scratch. No third-party code or license applies; the Actor has no upstream open-source dependency.

# Actor input Schema

## `sex` (type: `string`):

Biological sex used by the Mifflin-St Jeor equation. Accepted values: male or female.

## `ageYears` (type: `number`):

Age in years, between 15 and 100.

## `weightKg` (type: `number`):

Body weight in kilograms, between 30 and 300.

## `heightCm` (type: `number`):

Height in centimetres, between 100 and 250.

## `activityLevel` (type: `string`):

Activity multiplier: sedentary 1.2, light 1.375, moderate 1.55, active 1.725, veryActive 1.9.

## `goal` (type: `string`):

lose = 20 percent calorie deficit, maintain = TDEE, gain = 10 percent surplus.

## `dietType` (type: `string`):

Macro split of calories (protein/carbs/fat): balanced 25/45/30, highProtein 35/35/30, lowCarb 30/20/50, keto 20/5/75.

## `mealsPerDay` (type: `integer`):

Whole number of meals from 1 to 8; calories and macros are split equally across them.

## Actor input object example

```json
{
  "sex": "male",
  "ageYears": 30,
  "weightKg": 80,
  "heightCm": 180,
  "activityLevel": "moderate",
  "goal": "maintain",
  "dietType": "balanced",
  "mealsPerDay": 3
}
```

# Actor output Schema

## `results` (type: `string`):

One row per processed input

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "sex": "male",
    "ageYears": 30,
    "weightKg": 80,
    "heightCm": 180
};

// Run the Actor and wait for it to finish
const run = await client.actor("chun_yung_lo/tdee-macro-calculator").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "sex": "male",
    "ageYears": 30,
    "weightKg": 80,
    "heightCm": 180,
}

# Run the Actor and wait for it to finish
run = client.actor("chun_yung_lo/tdee-macro-calculator").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "sex": "male",
  "ageYears": 30,
  "weightKg": 80,
  "heightCm": 180
}' |
apify call chun_yung_lo/tdee-macro-calculator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,chun_yung_lo/tdee-macro-calculator"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/vSgsqXI5kJra9cnl2/builds/EeEtZ7vXwqJCRmvTQ/openapi.json
