Pace Calculator API: The Complete Guide

Need to calculate running pace in your fitness application? This guide covers everything you need to know about pace calculation via API, including pace conversions, race predictions, and implementation examples in multiple languages.

What is Running Pace?

Running pace is the time it takes to cover a unit of distance, typically expressed as minutes per kilometer (min/km) or minutes per mile (min/mi). It's the inverse of speed and is the preferred metric for runners because it directly translates to race finish times.

For example, a pace of 5:00 min/km means running 12 km/h. A marathon (42.195 km) at this pace would take 3:30:58.

Pace Calculations

Common pace-related calculations:

Time to Pace

Given a distance and finish time, calculate the required pace. Useful for race planning and goal setting.

Pace to Finish Time

Given a pace and distance, predict the finish time. Essential for race day pacing strategy.

Race Prediction

Using a recent race result, predict finish times for other distances using formulas like Riegel's.

Splits Calculator

Calculate split times for each kilometer or mile of a race based on target pace.

Tip: Even pacing or slight negative splits (running the second half faster) typically leads to better race results than positive splits.

Using the Pace Calculator API

TinyFn provides a simple endpoint to calculate running pace:

API Request
GET https://api.tinyfn.io/v1/fitness/pace?distance=42.195&time=210
Headers: X-API-Key: your-api-key
Response
{
  "distance_km": 42.195,
  "time_minutes": 210,
  "time_formatted": "3:30:00",
  "pace": {
    "min_per_km": "4:58",
    "min_per_mile": "8:00",
    "seconds_per_km": 298
  },
  "speed": {
    "kmh": 12.06,
    "mph": 7.49
  },
  "splits": {
    "5k": "24:52",
    "10k": "49:44",
    "half_marathon": "1:44:52"
  }
}

Parameters

Parameter Type Description
distance number Distance in kilometers
time number Time in minutes (for pace calculation)
pace string Pace as "MM:SS" (for finish time calculation)
unit string Distance unit: km (default) or miles

Code Examples

JavaScript / Node.js

const response = await fetch(
  'https://api.tinyfn.io/v1/fitness/pace?distance=42.195&time=210',
  { headers: { 'X-API-Key': 'your-api-key' } }
);
const data = await response.json();
console.log(`Pace: ${data.pace.min_per_km}/km`); // Pace: 4:58/km

Python

import requests

response = requests.get(
    'https://api.tinyfn.io/v1/fitness/pace',
    params={'distance': 42.195, 'time': 210},
    headers={'X-API-Key': 'your-api-key'}
)
data = response.json()
print(f"Marathon at {data['pace']['min_per_km']}/km = {data['time_formatted']}")

cURL

curl "https://api.tinyfn.io/v1/fitness/pace?distance=42.195&time=210" \
  -H "X-API-Key: your-api-key"

Common Use Cases

  • Running Apps: Display real-time pace during workouts
  • Race Planning: Set target paces and predict finish times
  • Training Platforms: Calculate training paces for different workout types
  • Virtual Races: Track and verify race performances
  • Coaching Tools: Create pace-based training programs

Best Practices

  1. Support both units: Allow users to choose km or miles
  2. Show intermediate splits: Display expected times at common checkpoints
  3. Include speed: Some users prefer km/h over pace
  4. Format times nicely: Use "3:30:00" format, not raw minutes

Try the Pace Calculator API

Get your free API key and start calculating pace in seconds.

Get Free API Key

Ready to try TinyFn?

Get your free API key and start building in minutes.

Get Free API Key