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.
Using the Pace Calculator API
TinyFn provides a simple endpoint to calculate running pace:
GET https://api.tinyfn.io/v1/fitness/pace?distance=42.195&time=210
Headers: X-API-Key: your-api-key
{
"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
- Support both units: Allow users to choose km or miles
- Show intermediate splits: Display expected times at common checkpoints
- Include speed: Some users prefer km/h over pace
- 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