API Almanac
API reference › Units

Convert a value between two units of the same kind

GET/v1/units/convert

GET/v1/units/convert

Convert a value between two units of the same kind

Units are matched loosely: km/h, kph and kilometers per hour are the same thing.

PARAMETERS
valuequery · numberREQUIRED
The quantity to convert
e.g. 26.2
fromquery · stringREQUIRED
Unit of `value`
e.g. mi
toquery · stringREQUIRED
Unit to convert into
e.g. km
In the full reference
REQUEST
curl "https://api.apialmanac.com/v1/units/convert?value=26.2&from=mi&to=km" \
  -H "X-API-Key: YOUR_KEY"
RESPONSE
200OK
{
  "value": 26.2,
  "from": {
    "id": "mi",
    "label": "mile"
  },
  "to": {
    "id": "km",
    "label": "kilometre"
  },
  "category": "length",
  "result": 42.164813,
  "formatted": "42.164813 km"
}
Try it — sign in first
Runs on a sandbox key: 200 requests a month. Your real key is for production.