Unit Handling Tutorial
Last updated
Was this helpful?
Last updated
Was this helpful?
To add a new measurement unit to your configuration, you need to send a request to the Adding a new unit endpoint.
Unit names are localized. When creating a new unit, you can specify the unit name in two different ways — in one language or in multiple languages.
Looking for more info on localization? Check out Standard practices.
curl -L \
--request POST \
--url 'https://api.emporix.io/unit-handling/{tenant}/units' \
--header 'Content-Language: fr' \
--header 'Content-Type: application/json' \
--data '{
"code": "kg",
"name": "kilogram",
"type": "mass",
"baseUnit": true,
"symbol": "kg",
"factor": 1
}'
You can convert between any measurement units that share the same base unit, such as kilograms to grams, or centimeters to meters.
To convert between units, you need to send a request to the Converting units endpoint.
curl -L \
--request PUT \
--url 'https://api.emporix.io/unit-handling/{tenant}/units/convert-unit-commands' \
--header 'Content-Type: application/json' \
--data '{
"commandUuid": "text",
"input": {
"sourceUnitAmount": 100,
"sourceUnit": "g",
"targetUnit": "kg"
}
}'
To test the endpoint, open the API reference below or check the example of a curl request.
To test the endpoint, open the API reference below or check the example of a curl request.