Speed Converter API: The Complete Guide

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 HourkmhMost countries
Miles per HourmphUS, UK
Meters per SecondmsScience
Feet per SecondfpsEngineering
KnotsknAviation, Maritime
MachmachAviation
Common Conversions: 1 mph = 1.60934 km/h, 1 knot = 1.852 km/h, 1 m/s = 3.6 km/h

Using the Speed Converter API

TinyFn provides a dedicated endpoint for speed conversions:

API Request
GET https://api.tinyfn.io/v1/convert/speed
Headers: X-API-Key: your-api-key
Response
{
  "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

  1. Default by region: Use mph for US/UK, km/h elsewhere
  2. Show both units: Display primary and secondary speed
  3. Use appropriate precision: Whole numbers usually suffice
  4. 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

Ready to try TinyFn?

Get your free API key and start building in minutes.

Get Free API Key