Unit Conversion API
The Unit Conversion API converts between different units of measurement.
Checking API status...
/v1/unitconversion GET
https://api.api-ninjas.com/v1/unitconversion
Returns conversions between different units of the same measurement type.
Parameters
- amountrequired- The numerical value to convert. 
- unitrequired- The source unit to convert from. Spaces should be replaced with underscores. See Supported Measurement Types for a list of available units. 
Headers
- X-Api-Keyrequired- API Key associated with your account. 
Response
Returns a JSON object with the following properties:
- typerequired- The measurement type (e.g., length, volume, temperature, etc.). 
- unitrequired- The source unit that was converted from. 
- amountrequired- The original amount to convert. 
- conversionsrequired- An 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!
https://api.api-ninjas.com/v1/unitconversion?amount=5&unit=meterHeaders
X-Api-KeyLog in or sign up to get your API KeySample Response
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{
  "type": "length",
  "unit": "meter",
  "amount": 5,
  "conversions": {
    "meter": 5,
    "kilometer": 0.005,
    "centimeter": 500,
    "millimeter": 5000,
    "micrometer": 5000000,
    "nanometer": 5000000000,
    "mile": 0.00310686,
    "yard": 5.46806649,
    "foot": 16.4041995,
    "inch": 196.850394,
    "nautical_mile": 0.00269978,
    "furlong": 0.02485485,
    "light_year": 0,
    "astronomical_unit": 0
  }
}Code Examples
1
2
curl -X GET "https://api.api-ninjas.com/v1/unitconversion?from_unit=miles&to_unit=kilometers&value=1" \
  -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.