UnifyUnits Developers

Locale formatting

Add format_locale to a request and the result gains a formatted string ready to show to people. The exact value is never changed, so you can keep computing with it.

bash
curl "https://api.unifyunits.com/v1/convert" \
  -X POST \
  -H "Authorization: Bearer $UNIFYUNITS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"value":"1500","from":"m","to":"km","format_locale":"de-DE"}'
json
{
  "data": {
    "input": { "value": "1500", "unit": "m" },
    "result": { "value": "1.5", "unit": "km", "formatted": "1,5 km" },
    "category": "length"
  }
}

Examples

Resultformat_localeformatted
1.5 kmde-DE1,5 km
1234.56 kgde1.234,56 kg
1234.56 kgen-US1,234.56 kg
64.00 GBP (currency)de-DE64,00 £

Rules

  • Works on convert, batch (applied to every successful item), parse (when to is set), currency conversion, and substance conversion. Pass it as a query parameter on GET requests. Normalize and unit price do not format output.
  • The digits shown are exactly the digits of value, trailing zeros included. Use decimals to control them: decimals: 2 gives 64,00 £, not 64 £.
  • Units that have a standard localized name (metres, kilograms, litres, miles, and others) use it. Other units show the number followed by the unit symbol, for example 101.325 kPa. Currencies use the locale's symbol and placement.
  • A language tag that is malformed or unknown returns INVALID_REQUEST (HTTP 400). Use hyphens, for example de-DE, not de_DE.
  • Requires the Developer plan or higher (PLAN_REQUIRED otherwise).
  • This is separate from the locale option of Normalize and unit price, which controls how input numbers like 1,5 are read.