NewConnect Claude, Gemini, 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
361ms401ms426ms785ms1065ms

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 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=meter

Headers

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

Sample Response

JSON
{
    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?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

  • 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.
  • Sign up for a free account to instantly get your API key, then pass it in the X-Api-Key header on every request. The documentation above includes ready-to-run examples in cURL, Python, JavaScript, Node.js, and more.
  • 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.
  • 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.
  • Send a GET request to /v1/unitconversion with the required amount parameter (the numerical value) and the unit parameter (the source unit, with spaces replaced by underscores such as nautical_mile). The response returns the measurement type, the source unit, the original amount, and a conversions object giving the converted value for every other unit of the same type; see error codes if a request is unsuccessful.
  • The API covers 12 measurement types: length, volume, area, temperature, weight, time, speed, force, power, pressure, and energy, with units such as meter, gallon, celsius, pound, knot, and kilowatt_hour. Browse other utilities in the API catalog.
  • 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.
  • Each result is keyed by the target unit name inside the conversions object, so a meter request lets you read conversions.kilometer or conversions.foot directly. Only units within the source unit's measurement type are returned; see the full API list for related tools.