Heart Rate Zone API: The Complete Guide

Need to calculate heart rate training zones in your fitness application? This guide covers everything you need to know about heart rate zone calculation via API, including different formulas, zone definitions, and implementation examples.

What are Heart Rate Zones?

Heart rate zones are ranges of heart rates that correspond to different exercise intensities. Training in specific zones helps optimize workouts for different goals: fat burning, endurance, speed, or maximum performance.

Zones are typically calculated as percentages of your maximum heart rate (MHR) or using the Karvonen formula with heart rate reserve (HRR).

Zone Definitions

The five traditional heart rate zones:

Zone 1: Recovery (50-60% MHR)

Very light effort. Warm-up, cool-down, and active recovery. Improves overall health and recovery.

Zone 2: Aerobic (60-70% MHR)

Light effort, can hold conversation. Builds aerobic base, burns fat, improves endurance.

Zone 3: Tempo (70-80% MHR)

Moderate effort, breathing harder. Improves aerobic capacity and efficiency.

Zone 4: Threshold (80-90% MHR)

Hard effort, difficult to talk. Increases lactate threshold and speed.

Zone 5: Maximum (90-100% MHR)

Maximum effort, very short bursts only. Develops maximum performance and speed.

Karvonen Method: More accurate than simple percentage of max HR, as it accounts for resting heart rate to calculate heart rate reserve.

Using the Heart Rate Zone API

TinyFn provides a simple endpoint to calculate heart rate zones:

API Request
GET https://api.tinyfn.io/v1/health/heart-rate-zones?age=30&resting_hr=60
Headers: X-API-Key: your-api-key
Response
{
  "max_heart_rate": 190,
  "resting_heart_rate": 60,
  "heart_rate_reserve": 130,
  "zones": {
    "zone1": {"name": "Recovery", "min": 125, "max": 138, "percent": "50-60%"},
    "zone2": {"name": "Aerobic", "min": 138, "max": 151, "percent": "60-70%"},
    "zone3": {"name": "Tempo", "min": 151, "max": 164, "percent": "70-80%"},
    "zone4": {"name": "Threshold", "min": 164, "max": 177, "percent": "80-90%"},
    "zone5": {"name": "Maximum", "min": 177, "max": 190, "percent": "90-100%"}
  },
  "method": "karvonen"
}

Parameters

Parameter Type Description
age integer Age in years (for max HR calculation)
max_hr integer Known maximum heart rate (optional, overrides age calculation)
resting_hr integer Resting heart rate (optional, for Karvonen method)
method string Calculation method: karvonen or percentage (default)

Code Examples

JavaScript / Node.js

const response = await fetch(
  'https://api.tinyfn.io/v1/health/heart-rate-zones?age=30&resting_hr=60',
  { headers: { 'X-API-Key': 'your-api-key' } }
);
const data = await response.json();
console.log(`Zone 2: ${data.zones.zone2.min}-${data.zones.zone2.max} bpm`); // Zone 2: 138-151 bpm

Python

import requests

response = requests.get(
    'https://api.tinyfn.io/v1/health/heart-rate-zones',
    params={'age': 30, 'resting_hr': 60},
    headers={'X-API-Key': 'your-api-key'}
)
data = response.json()
for zone_id, zone in data['zones'].items():
    print(f"{zone['name']}: {zone['min']}-{zone['max']} bpm")

cURL

curl "https://api.tinyfn.io/v1/health/heart-rate-zones?age=30&resting_hr=60" \
  -H "X-API-Key: your-api-key"

Common Use Cases

  • Workout Apps: Guide users to train in the right zone for their goals
  • Wearable Integrations: Display real-time zone feedback during exercise
  • Training Plans: Structure workouts with specific zone targets
  • Fitness Coaching: Create personalized cardio programs
  • Health Dashboards: Visualize training intensity distributions

Best Practices

  1. Use Karvonen for accuracy: When resting HR is available, use Karvonen method
  2. Measure actual max HR: Lab-tested or field-tested max HR is more accurate than formulas
  3. Update resting HR: Recalculate zones as fitness improves and resting HR drops
  4. Show zone names: Display descriptive names, not just numbers

Use via MCP

Your AI agent can call this tool directly via Model Context Protocol — no HTTP code needed. Add TinyFn to Claude Desktop, Cursor, or any MCP client:

{
  "mcpServers": {
    "tinyfn-health": {
      "url": "https://api.tinyfn.io/mcp/health/",
      "headers": {
        "X-API-Key": "your-api-key"
      }
    }
  }
}

See all health tools available via MCP in our Health MCP Tools for AI Agents guide.

Try the Heart Rate Zone API

Get your free API key and start calculating heart rate zones in seconds.

Get Free API Key

Ready to try TinyFn?

Get your free API key and start building in minutes.

Get Free API Key