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 converte.g. 26.2
- fromquery · stringREQUIRED
- Unit of `value`e.g. mi
- toquery · stringREQUIRED
- Unit to convert intoe.g. km
REQUEST
curl "https://api.apialmanac.com/v1/units/convert?value=26.2&from=mi&to=km" \ -H "X-API-Key: YOUR_KEY"
import requests
r = requests.get("https://api.apialmanac.com/v1/units/convert?value=26.2&from=mi&to=km", headers={"X-API-Key": "YOUR_KEY"})
print(r.status_code, r.headers.get("X-Gw-Remaining"))
print(r.json())
const r = await fetch("https://api.apialmanac.com/v1/units/convert?value=26.2&from=mi&to=km", {
headers: { "X-API-Key": "YOUR_KEY" }
});
console.log(r.status, r.headers.get("X-Gw-Remaining"));
console.log(await r.json());
RESPONSE
200OK
{
"value": 26.2,
"from": {
"id": "mi",
"label": "mile"
},
"to": {
"id": "km",
"label": "kilometre"
},
"category": "length",
"result": 42.164813,
"formatted": "42.164813 km"
}