Skip to content
moxon home

Unit Conversion

The /convert endpoint allows you to convert values between units of the same category. You need to provide a value to convert, a source unit, and the target unit.

gethttps://api.moxon.dev/v5/convert
Try itget/v5/convert

Parameters

  • valuestringrequired

    The numeric value to convert

  • fromstringrequired

    The source unit (see available units below)

    • celsius
    • fahrenheit
    • kelvin
    • km
    • mi
    • m
    • ft
    • cm
    • in
    • yd
    • kg
    • lb
    • oz
    • g
    • ton
    • b
    • kb
    • mb
    • gb
    • tb
    • km/h
    • mph
    • m/s
    • knots
  • tostringrequired

    The target unit (must be in the same category as from)

    • celsius
    • fahrenheit
    • kelvin
    • km
    • mi
    • m
    • ft
    • cm
    • in
    • yd
    • kg
    • lb
    • oz
    • g
    • ton
    • b
    • kb
    • mb
    • gb
    • tb
    • km/h
    • mph
    • m/s
    • knots

Available Units

Temperature:

UnitDescription
celsiusCelsius degrees
fahrenheitFahrenheit degrees
kelvinKelvin

Length:

UnitDescription
kmKilometers
miMiles
mMeters
ftFeet
cmCentimeters
inInches
ydYards

Weight:

UnitDescription
kgKilograms
lbPounds
ozOunces
gGrams
tonMetric tons

Data:

UnitDescription
bBytes
kbKilobytes
mbMegabytes
gbGigabytes
tbTerabytes

Speed:

UnitDescription
km/hKilometers/hour
mphMiles/hour
m/sMeters/second
knotsKnots

Response Fields

  • fromstring

    Source unit

  • tostring

    Target unit

  • valuenumber

    Original value to convert

  • resultnumber

    Converted value

Code Examples

Error Handling

If parameters are missing or invalid, the API will return an error:

  • 400Please provide a valid value (?value={value})The value parameter is missing or invalid
  • 400Please provide a valid source unit (&from={unit})The from parameter is missing or invalid
  • 400Please provide a valid target unit (&to={unit})The to parameter is missing or invalid
  • 400Value must be a numberThe value is not a valid number
  • 400Invalid conversion unitThe from/to combination is not valid
  • 400Value must be greater than absolute zeroThe value is below absolute zero (temperature only)