Unit conversion
What this does
Converts a numeric value from one unit to another. Supports everyday pairs such as miles to kilometres, pounds to kilograms, Celsius to Fahrenheit, and litres to pints. You send what you have; the API returns the equivalent.
Who it is for
- Product specs crossing metric and imperial
- Recipe and brewing calculators
- Fitness apps (stones to kg)
- School homework and quick sanity checks
Try it
10 miles to kilometres:
https://fetch.li/v1/convert?from=mi&to=km&value=10
Other examples:
https://fetch.li/v1/convert?from=c&to=f&value=20
https://fetch.li/v1/convert?from=lb&to=kg&value=150
https://fetch.li/v1/convert?from=l&to=pt&value=2
HTTP example
GET /v1/convert?from=mi&to=km&value=10 HTTP/1.1
Host: fetch.li
Accept: application/json
curl
curl -sS "https://fetch.li/v1/convert?from=mi&to=km&value=10"
JavaScript fetch
const params = new URLSearchParams({ from: "mi", to: "km", value: "10" });
const response = await fetch(`https://fetch.li/v1/convert?${params}`);
const result = await response.json();
console.log(result.value, result.unit);
Python requests
import requests
response = requests.get(
"https://fetch.li/v1/convert",
params={"from": "mi", "to": "km", "value": 10},
)
response.raise_for_status()
print(response.json())
Example JSON response
{
"from": "mi",
"to": "km",
"input": 10,
"value": 16.0934,
"unit": "km",
"formula": "1 mi = 1.60934 km"
}
Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
from |
Yes | string | Source unit code (e.g. mi, km, c, f, lb, kg, l, pt, m, ft) |
to |
Yes | string | Target unit code |
value |
Yes | number | Numeric value in the source unit |
Supported units are listed in the API catalog (GET /v1). Incompatible pairs return invalid_body.
Errors that can happen
| HTTP | error.code |
When |
|---|---|---|
| 400 | invalid_body |
Unknown unit, incompatible categories, or missing parameter |
| 429 | rate_limited |
Demo limit exceeded |
| 500 | internal |
Unexpected server error |
Demo
GET endpoints work without an API key on the public demo tier (60 calls per hour per IP). POST /v1/vibe/classify needs a key.