NewConnect Claude, Cursor, ChatGPT, and other AI agents to API Ninjas via our MCP server

Unit Conversion API

The Unit Conversion API converts between different units of measurement.

(4.4)

From 4,537 users

2,700+

Applications using this API

API Status

Online - All Systems Operational

API Response Times

Average
P50
P75
P90
P95
369ms416ms422ms707ms1034ms

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

  • amount  required

    The numerical value to convert.

  • unit  required

    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-Key  required

    API Key associated with your account.

Response

A JSON object with the following fields or an error if the request is unsuccessful.

  • type  required

    The measurement type (e.g., length, volume, temperature, etc.).

  • unit  required

    The source unit that was converted from.

  • amount  required

    The original amount to convert.

  • conversions  required

    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!

amount
unit

Try this API endpoint with all available parameters in our API playground

https://api.api-ninjas.com/v1/unitconversion?amount=5&unit=meter

Headers

X-Api-KeyLog in or sign up to get your API Key

Sample Response

JSON

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.