Convert Units API

Convert units from one to another. The API returns the amount and the unit of the target unit.

For each type, there are many units that can be converted to each other. For example, for the type "bandwidth", you can convert from "bit/s" to "kb/s", "mb/s", "gb/s" and so on. Here's a list of physical unit types understood and convertable by the API:

  • Bandwidth (bit/s, kb/s...)
  • Time (hours, minutes, seconds...)
  • Digital (byte, megabyte...)
  • Frequency (Hz, kHz...)
  • Rotation Speed (rpm...)
  • Length (miles, centimeters, nanometers...)
  • Area (sqft, m²...)
  • Temperature (celsius, fahrenheit, °C...)
  • Area Density (g/m²...)
  • Density (kg/m³...)
  • Volume (liter, gallons, cm³...)
  • Power Ratio (dB, decibel...)
  • Weight (grams, lbs, tons...)
  • Force (N, Newton...)
  • Speed (km/h, mph...)
  • Pressure (pascal, hPa...)
  • Electrical Resistance (ohm, Ω...)
  • Power (W, Watt, kW...)
  • Voltage (volts, mV...)
  • Energy (kilojoule, calories, kcal...)
  • Current (ampere, amp...)
  • Electric Charge (ampere-hour, Ah...)
  • Torque (Nm, ft-pdl, mkgf...)
  • Pixel (pixel, megapixel...)
  • Luminance (nit, cd/m²...)
  • Luminous Flux (lumen, lm...)
  • Flow Rate (m³/s, us gpm, gallons per minute...)

Additionally, you can convert food amounts and the correct food density will be used to convert the amount. For example, you can convert from "1 cup of flour" to "grams" or "ounces". Given "flour" as the food name, you will get a different conversion than using oil or water for instance as the densities are very different from flour.

GET
https://api.apileague.com/convert-units
Example Request and Response
GET
https://api.apileague.com/{{ examples.getConvertUnits }}
{
    "target_amount": 220.46226218487757,
    "target_unit": "lb"
}
cURL
Java
Javascript
Python
Go
C#
 {{ codeCopyText }}
 {{ codeCopyText }}
 {{ codeCopyText }}
 {{ codeCopyText }}
 {{ codeCopyText }}
 {{ codeCopyText }}

Frequently Asked Questions

What units can be converted?

The API supports a wide range of physical units including bandwidth, time, length, area, volume, weight, temperature, speed, pressure, energy, and more.

Can I convert food ingredients?

Yes, the API can convert food amounts (e.g., "1 cup of flour" to "grams") by using the specific density of the food item to ensure accurate conversion.

How accurate are the conversions?

The conversions are based on standard physical constants and precise food density data, providing highly accurate results for both physical and culinary conversions.

How is the Convert Units API different from the Compute Nutrition API?

The Convert Units API focuses on physical unit conversions and simple food quantity conversions, while the Compute Nutrition API calculates detailed nutritional profiles for recipes.

Questions? Need Help? Ask Away