Unit Conversion API
The Unit Conversion API converts between different units of measurement.
From 4,537 users
Applications using this API
API Status
API Response Times
Average | P50 | P75 | P90 | P95 |
|---|---|---|---|---|
| 361ms | 401ms | 426ms | 785ms | 1065ms |
Similar APIs
Didn't find what you were looking for? Suggest an improvement
/v1/unitconversion GET
https://api.api-ninjas.com/v1/unitconversion
Returns conversions between different units of the same measurement type.
Parameters
amountrequiredThe numerical value to convert.
unitrequiredThe source unit to convert from. Spaces should be replaced with underscores. See Supported Measurement Types for a list of available units.
Headers
X-Api-KeyrequiredAPI Key associated with your account.
Response
A JSON object with the following fields or an error if the request is unsuccessful.
typerequiredThe measurement type (e.g., length, volume, temperature, etc.).
unitrequiredThe source unit that was converted from.
amountrequiredThe original amount to convert.
conversionsrequiredAn object containing all the converted values for each unit of the same measurement type.
Supported Measurement Types
The API supports the following measurement types and units:
Length
meter, kilometer, centimeter, millimeter, micrometer, nanometer, mile, yard, foot, inch, nautical_mile, furlong, light_year, astronomical_unit
Volume
cubic_meter, liter, milliliter, gallon, quart, pint, cup, fluid_ounce, tablespoon, teaspoon, cubic_foot, cubic_inch, cubic_centimeter, cubic_millimeter
Area
square_meter, square_kilometer, square_centimeter, square_millimeter, square_mile, square_yard, square_foot, square_inch, acre, hectare
Temperature
celsius, fahrenheit, kelvin
Weight
kilogram, gram, milligram, metric_ton, pound, ounce, stone, us_ton, imperial_ton, carat
Time
second, millisecond, microsecond, nanosecond, minute, hour, day, week, month, year, decade, century
Speed
meter_per_second, kilometer_per_hour, mile_per_hour, knot, foot_per_second
Force
newton, kilonewton, pound_force, dyne
Power
watt, kilowatt, megawatt, horsepower, btu_per_hour
Pressure
pascal, kilopascal, megapascal, bar, psi, atmosphere, torr, millimeter_of_mercury
Energy
joule, kilojoule, calorie, kilocalorie, watt_hour, kilowatt_hour, electron_volt, british_thermal_unit, us_therm, foot_pound
Sample Request Live Demo!
Try our APIs in the API playground
Sign up for a free API key to get started — no credit card required.
https://api.api-ninjas.com/v1/unitconversion?amount=5&unit=meterHeaders
X-Api-KeyLog in or sign up to get your API KeySample Response
Code Examples
1
2
curl -X GET "https://api.api-ninjas.com/v1/unitconversion?amount=5&unit=meter" \
-H "X-Api-Key: YOUR_API_KEY"If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.
Frequently Asked Questions
Can I use the Unit Conversion API for commercial purposes?
Yes, but you must have a premium subscription. Commercial use of the Unit Conversion API is not permitted on the free tier. See our pricing page to choose a plan that fits your needs.How do I get an API key and start using the Unit Conversion API?
Sign up for a free account to instantly get your API key, then pass it in theX-Api-Keyheader on every request. The documentation above includes ready-to-run examples in cURL, Python, JavaScript, Node.js, and more.What happens if I exceed my quota for the month?
Your API requests will simply be denied once you hit your monthly quota — you will never be charged more than the plan you signed up for. To increase your quota, you can upgrade your plan any time on our pricing page.What happens if a request to the Unit Conversion API fails?
The API responds with a standard HTTP status code and a JSON error message describing the problem. See our error codes reference for the full list of codes and how to resolve each one, or contact support if you need help.How do I convert a value, and what does the response include?
Send a GET request to/v1/unitconversionwith the requiredamountparameter (the numerical value) and theunitparameter (the source unit, with spaces replaced by underscores such asnautical_mile). The response returns the measurementtype, the sourceunit, the originalamount, and aconversionsobject giving the converted value for every other unit of the same type; see error codes if a request is unsuccessful.What units and measurement types are supported?
The API covers 12 measurement types: length, volume, area, temperature, weight, time, speed, force, power, pressure, and energy, with units such asmeter,gallon,celsius,pound,knot, andkilowatt_hour. Browse other utilities in the API catalog.Can this API convert between currencies like USD to EUR?
No, the Unit Conversion API only handles physical units of measurement and does not include currencies. For money conversions use the Convert Currency API, or fetch live rates with the Exchange Rate API.How do I read the converted value for a specific target unit?
Each result is keyed by the target unit name inside theconversionsobject, so ameterrequest lets you readconversions.kilometerorconversions.footdirectly. Only units within the source unit's measurement type are returned; see the full API list for related tools.