Unit conversion API
The same engine that powers the site, as JSON. 107 units in 12 categories, free, no key, no account, CORS enabled so it works from a browser. Currency rates are not part of the API; use the European Central Bank feeds directly.
Convert
GET https://unitswapper.net/api/v1/convert?from=<unit>&to=<unit>&value=<number>
Units accept full identifiers (kilometer) or the short aliases used in URLs and by people (km, lbs, miles, celsius, f). Aliases that are ambiguous across categories (ms) resolve to the speed unit; use the full identifier to be explicit.
curl "https://unitswapper.net/api/v1/convert?from=km&to=mile&value=10"
{
"result": 6.21371192237334,
"from": "kilometer",
"to": "mile",
"value": 10,
"formula": "1 km = 0.621371 mi"
}The same call as POST with a JSON body:
curl -X POST https://unitswapper.net/api/v1/convert \
-H "Content-Type: application/json" \
-d '{"from":"celsius","to":"fahrenheit","value":37}'
{ "result": 98.6, "from": "celsius", "to": "fahrenheit", "value": 37, "formula": "F = C x 9/5 + 32" }result is the full double-precision value; round it yourself for display (the website shows six significant digits).
List units and categories
GET https://unitswapper.net/api/v1/categories
{ "categories": [ { "id": "length", "name": "Length", "unitCount": 16 }, ... ] }
GET https://unitswapper.net/api/v1/units
GET https://unitswapper.net/api/v1/units?category=weight
{ "category": "weight", "units": [ { "id": "kilogram", "name": "Kilogram", "plural": "Kilograms", "symbol": "kg", "category": "weight" }, ... ] }Errors
| 400 | Missing or invalid parameter, unknown unit, or units from two different categories. The error field says which. |
| 404 | Unknown category on /units. |
| 422 | The result is not a finite number (overflow, or a temperature below absolute zero). |
| 429 | More than 600 requests per minute from one IP address. Wait for the Retry-After delay. |
Embed the converter on your site
A self-contained converter for one category, with an attribution link. It works from any domain (the page allows every frame ancestor) and follows the visitor's light or dark theme. Parameters: category (length, weight, temperature, area, volume, speed, data, time, pressure, energy, power, fuel), from, to (unit ids or aliases) and value.
<iframe
src="https://unitswapper.net/embed?category=length&from=km&to=mile&value=10"
title="Kilometers to miles converter"
width="100%" height="260" style="border:0" loading="lazy"></iframe>Preview. The embed sends nothing to us except the page view counted by our cookieless analytics; see the privacy policy.
Terms
Free for personal and commercial use, no attribution required. Please cache results on your side (factors do not change) and do not resell the API as a service. Accuracy and sources are documented on the methodology page; the full terms of service apply. Questions or a factor to dispute: [email protected].