UnifyUnits Developers

Precision & numeric values

Values are always decimal strings, not JSON numbers. This preserves decimal intent and avoids binary floating-point loss.
Docs stay in sync with the API. Any new request parameter, response field, default, or rounding rule must update this docs app in the same change (endpoint pages, guides, OpenAPI, and this precision page as needed).

Correct vs invalid

json
{"value": "0.1", "from": "m", "to": "cm"}

Not valid in v1:

json
{"value": 0.1, "from": "m", "to": "cm"}

Accepted formats

FormatExampleAccepted
Integer"10"Yes
Negative"-10"Only where the category allows it (for example temperature). Most categories, such as length and mass, return OUT_OF_RANGE
Decimal"10.5"Yes
Scientific"1.25e6"Yes
NaN / Infinity"NaN"No
Comma-separated"1,000"No
Fraction"1/2"No
With unit suffix"10 kg"No

Input limits

  • At most 256 characters before trimming whitespace
  • At most 100 significant digits
  • An explicit exponent of at most 1000 in absolute value
  • Request bodies are limited to 64 KiB (PAYLOAD_TOO_LARGE, HTTP 413)

Engine precision

Without decimals, terminating results keep their full decimal value. Nonterminating results use 40 significant digits with half-even rounding. Example:

json
{
  "value": "10",
  "from": "kg",
  "to": "lb"
}
// result.value → "22.04622621848775807229738013450270338542"

Optional decimals

Pass decimals (integer 0–40) on GET query, POST body, or each batch item to round only result.value after conversion. Rounding is half-even (same mode as the engine). input.value is not rounded, but it is echoed in canonical form (for example "1.25e6" comes back as "1250000").

bash
curl "https://api.unifyunits.com/v1/convert?value=10&from=kg&to=lb&decimals=2" \
  -H "Authorization: Bearer $UNIFYUNITS_API_KEY"
# result.value → "22.05"
json
{"value": "10", "from": "kg", "to": "lb", "decimals": 2}

Omit decimals for the full engine string. Unknown keys such as precision are rejected. When decimals is set, large or tiny results that the engine would emit in scientific notation are expanded to a fixed decimal string (for example "1e+22" with decimals: 2 becomes "10000000000000000000000.00").

Temperature

Temperature uses affine conversion (offset + scale). Results are deterministic for the same input under the same API version.

InputFromToResult
"32"FC"0"
"0"CK"273.15"
"-40"CF"-40"