A unit conversion API, and when a library is the better choice

A unit conversion API takes a value and two units and returns the result, so an app, spreadsheet or AI agent doesn't need its own conversion tables. Our Unit Converter API accepts plain text like "5 km to mi" or "30 mpg to l/100km" across 11 categories and about 110 units, using exact SI and NIST factors, for $0.002 per call. If you write Python or JavaScript, a library such as pint or convert-units does the same for free inside your code.

Try it free Unit Converter API — length, weight, data size and more, $0.002 · $0.002 / call

What it converts

CategoryExamples
Length, area, volumemm to in, acres to hectares, US gallons to litres, cups to ml
Masskg to lb, stone, carats, US short ton vs metric tonne
TemperatureCelsius, Fahrenheit, kelvin, Rankine (refuses below absolute zero)
Speed and timekm/h to mph, knots, seconds to days
Data sizeMB vs MiB, megabits to megabytes
Energy and pressurekWh to BTU, kcal to kJ, psi to bar
Fuel economympg (US or UK) to l/100km, which is an inverse, not a factor

The mistakes it guards against

Calling it

Results are rounded to 10 significant digits. The price is $0.002 per call, paid with x402.

curl -i -X POST https://iamai.markets/api/x402/services/Z4KHAvBd33cm \
  -H "Content-Type: application/json" \
  -d '{"query": "5 km to mi"}'

# result: {"category": "length", "result": 3.106855961, "text": "5 km = 3.106856 mi", ...}
# Structured form: {"value": 72, "from": "F", "to": "C"}

API or library

Be practical: unit conversion is a small, fixed piece of maths. If your code converts thousands of values a second, use pint (Python) or a JavaScript package and keep it in-process. The API fits places where adding a dependency is awkward, like no-code automations, Google Sheets scripts, chat bots, or an AI agent that needs a reliable answer instead of doing arithmetic from memory.

The product

Questions

Does it convert currencies?

No. Currency rates change daily; use an exchange rate API for that, such as our historical ECB rates API.

Can I send "72 degrees F in C"?

Yes. Words like "to", "in", "into" and "=" all work, and common spellings and plurals are recognised.

How accurate are the factors?

They are the exact defined values (an inch is exactly 2.54 cm), so the only rounding is the final 10 digits.

Related

Updated 2026-12-02