Need to convert speed units in your application? This guide covers everything you need to know about speed conversion via API, including automotive, aviation, and maritime speeds with implementation examples in multiple languages.
Understanding Speed Units
Speed measures how fast an object moves over a distance in a given time. Different regions and industries use different units: km/h is standard in most countries, mph in the US/UK, knots in aviation and maritime, and m/s in science.
Speed conversion is essential for navigation apps, fitness trackers, automotive applications, and weather services.
Supported Speed Units
| Unit | Code | Common Use |
|---|---|---|
| Kilometers per Hour | kmh | Most countries |
| Miles per Hour | mph | US, UK |
| Meters per Second | ms | Science |
| Feet per Second | fps | Engineering |
| Knots | kn | Aviation, Maritime |
| Mach | mach | Aviation |
Using the Speed Converter API
TinyFn provides a dedicated endpoint for speed conversions:
GET https://api.tinyfn.io/v1/convert/speed
Headers: X-API-Key: your-api-key
{
"from_unit": "mph",
"to_unit": "kmh",
"value": 60,
"result": 96.5606,
"formula": "60 × 1.60934"
}
Parameters
| Parameter | Type | Description |
|---|---|---|
from |
string | Source unit code (e.g., "mph") |
to |
string | Target unit code (e.g., "kmh") |
value |
number | Value to convert |
Code Examples
JavaScript / Node.js
const response = await fetch(
'https://api.tinyfn.io/v1/convert/speed?from=mph&to=kmh&value=60',
{ headers: { 'X-API-Key': 'your-api-key' } }
);
const data = await response.json();
console.log(data.result); // 96.5606
Python
import requests
response = requests.get(
'https://api.tinyfn.io/v1/convert/speed',
params={'from': 'mph', 'to': 'kmh', 'value': 60},
headers={'X-API-Key': 'your-api-key'}
)
data = response.json()
print(data['result']) # 96.5606
cURL
curl "https://api.tinyfn.io/v1/convert/speed?from=mph&to=kmh&value=60" \
-H "X-API-Key: your-api-key"
Common Use Cases
- Navigation Apps: Display speeds in user-preferred units
- Fitness Apps: Show running/cycling pace
- Weather Apps: Display wind speeds
- Aviation: Convert between knots and other units
- Automotive: International vehicle dashboards
Best Practices
- Default by region: Use mph for US/UK, km/h elsewhere
- Show both units: Display primary and secondary speed
- Use appropriate precision: Whole numbers usually suffice
- Context matters: Use knots for maritime/aviation contexts
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-convert": {
"url": "https://api.tinyfn.io/mcp/convert/",
"headers": {
"X-API-Key": "your-api-key"
}
}
}
}
See all conversion tools available via MCP in our Conversion MCP Tools for AI Agents guide.
Try the Speed Converter API
Get your free API key and start converting speeds in seconds.
Get Free API Key