Unit Conversion and Formatting API

API ID 15644

Exact unit conversion for length, mass, volume, temperature, data size (MB and MiB), pressure, energy, fuel economy and more, plus batch, quantity parsing and best-unit formatting.

API Documentation

Endpoints

Request
Same as the POST version, with query parameters.
Endpoint ID: 42327
GET https://zylalabs.com/api/15644/unit+conversion+and+formatting+api/42327/convert+a+value+between+two+units+using+get
INPUT PARAMETERS

Convert a value between two units using GET — Endpoint Features

Object Description
value Required Numeric value to convert
from Required Source unit code, e.g. C
to Required Target unit code, e.g. F
precision Optional Decimal places to round to (0-15)

Free test requests remaining: 3 of 3.


INPUT PARAMETERS

value
from
to
precision
API EXAMPLE RESPONSE
JSON
{
    "ok": true,
    "data": {
        "category": "temperature",
        "input": {
            "value": 100,
            "unit": {
                "code": "C",
                "name": "degree Celsius"
            }
        },
        "result": {
            "value": 212,
            "unit": {
                "code": "F",
                "name": "degree Fahrenheit"
            }
        },
        "formatted": "212 F",
        "exact": true,
        "note": "Temperatures are converted as absolute readings (offsets applied). For a temperature difference, convert C↔K 1:1 and C↔F by 9/5."
    }
}
Convert a value between two units using GET — CODE SNIPPETS

curl --location --request GET 'https://zylalabs.com/api/15644/unit+conversion+and+formatting+api/42327/convert+a+value+between+two+units+using+get?value=100&from=C&to=F&precision=2' --header 'Authorization: Bearer YOUR_API_KEY' 


    
Request
Converts value from one unit to another in the same category. Uses exact SI/NIST definitions (1 in = 2.54 cm, 1 lb = 0.45359237 kg, 1 US gal = 3.785411784 L). Temperatures apply offsets. Fuel economy handles the reciprocal L/100km scale. Returns the result, the factor for linear units, and whether the conversion is exact.
Endpoint ID: 42328
POST https://zylalabs.com/api/15644/unit+conversion+and+formatting+api/42328/convert+a+value+between+two+units
INPUT PARAMETERS

Convert a value between two units — Endpoint Features

Object Description
Request Body Required Json

Free test requests remaining: 3 of 3.


INPUT PARAMETERS

API EXAMPLE RESPONSE
JSON
{
    "ok": true,
    "data": {
        "category": "fuel",
        "input": {
            "value": 30,
            "unit": {
                "code": "mpg",
                "name": "miles per US gallon"
            }
        },
        "result": {
            "value": 7.84,
            "unit": {
                "code": "L/100km",
                "name": "liters per 100 kilometers"
            }
        },
        "formatted": "7.84 L/100km",
        "exact": true
    }
}
Convert a value between two units — CODE SNIPPETS

curl --location --request POST 'https://zylalabs.com/api/15644/unit+conversion+and+formatting+api/42328/convert+a+value+between+two+units' --header 'Authorization: Bearer YOUR_API_KEY' 

--data-raw '{"value":30,"from":"mpg","to":"L/100km","precision":2}'

    
Request
Lists every category with its base unit and each unit's code, name, aliases, exactness flag, and size in the base unit (linear units). Filter with category.
Endpoint ID: 42329
GET https://zylalabs.com/api/15644/unit+conversion+and+formatting+api/42329/list+unit+categories+and+codes
INPUT PARAMETERS

Free test requests remaining: 3 of 3.


INPUT PARAMETERS

API EXAMPLE RESPONSE
JSON
{
    "ok": true,
    "data": {
        "categoryCount": 1,
        "unitCount": 4,
        "categories": [
            {
                "id": "temperature",
                "label": "Temperature (absolute scale values, with offsets)",
                "baseUnit": "C",
                "units": [
                    {
                        "code": "C",
                        "name": "degree Celsius",
                        "aliases": [
                            "°C",
                            "ºC",
                            "degC",
                            "celsius",
                            "Celsius",
                            "centigrade"
                        ],
                        "exact": true
                    },
                    {
                        "code": "F",
                        "name": "degree Fahrenheit",
                        "aliases": [
                            "°F",
                            "ºF",
                            "degF",
                            "fahrenheit",
                            "Fahrenheit"
                        ],
                        "exact": true
                    },
                    {
                        "code": "K",
                        "name": "kelvin",
                        "aliases": [
                            "kelvin",
                            "Kelvin",
                            "kelvins"
                        ],
                        "exact": true
                    },
                    {
                        "code": "R",
                        "name": "degree Rankine",
                        "aliases": [
                            "°R",
                            "degR",
                            "rankine",
                            "Rankine"
                        ],
                        "exact": true
                    }
                ]
            }
        ],
        "note": "Codes and aliases are matched exactly first, then ignoring case when unambiguous. Data units: B = byte, bit/b = bit; MB = 10^6 bytes, MiB = 2^20 bytes, Mb/Mbit = megabits. Lowercase mb/gb/tb are read as bytes."
    }
}
List unit categories and codes — CODE SNIPPETS

curl --location --request GET 'https://zylalabs.com/api/15644/unit+conversion+and+formatting+api/42329/list+unit+categories+and+codes' --header 'Authorization: Bearer YOUR_API_KEY' 


    
Request
Each item is {value, from, to} with optional precision or significantDigits. Top-level precision and significantDigits apply to every item unless an item overrides them. Errors are reported per item, so one bad item does not fail the batch.
Endpoint ID: 42330
POST https://zylalabs.com/api/15644/unit+conversion+and+formatting+api/42330/convert+up+to+100+values+in+one+call
INPUT PARAMETERS

Convert up to 100 values in one call — Endpoint Features

Object Description
Request Body Required Json

Free test requests remaining: 3 of 3.


INPUT PARAMETERS

API EXAMPLE RESPONSE
JSON
{
    "ok": true,
    "data": {
        "count": 3,
        "succeeded": 2,
        "failed": 1,
        "results": [
            {
                "index": 0,
                "ok": true,
                "data": {
                    "category": "length",
                    "input": {
                        "value": 1,
                        "unit": {
                            "code": "mi",
                            "name": "mile"
                        }
                    },
                    "result": {
                        "value": 1.6093,
                        "unit": {
                            "code": "km",
                            "name": "kilometer"
                        }
                    },
                    "formatted": "1.6093 km",
                    "exact": true,
                    "factor": 1.609344
                }
            },
            {
                "index": 1,
                "ok": true,
                "data": {
                    "category": "data",
                    "input": {
                        "value": 1,
                        "unit": {
                            "code": "GiB",
                            "name": "gibibyte (1024^3 B)"
                        }
                    },
                    "result": {
                        "value": 1.0737,
                        "unit": {
                            "code": "GB",
                            "name": "gigabyte (10^9 B)"
                        }
                    },
                    "formatted": "1.0737 GB",
                    "exact": true,
                    "factor": 1.073741824
                }
            },
            {
                "index": 2,
                "ok": false,
                "error": {
                    "code": "incompatible_units",
                    "message": "Cannot convert mass (kg) to length (m)."
                }
            }
        ]
    }
}
Convert up to 100 values in one call — CODE SNIPPETS

curl --location --request POST 'https://zylalabs.com/api/15644/unit+conversion+and+formatting+api/42330/convert+up+to+100+values+in+one+call' --header 'Authorization: Bearer YOUR_API_KEY' 

--data-raw '{"precision":4,"items":[{"value":1,"from":"mi","to":"km"},{"value":1,"from":"GiB","to":"GB"},{"value":1,"from":"kg","to":"m"}]}'

    
Request
Same as the POST version, with query parameters.
Endpoint ID: 42331
GET https://zylalabs.com/api/15644/unit+conversion+and+formatting+api/42331/parse+a+quantity+string+using+get
INPUT PARAMETERS

Parse a quantity string using GET — Endpoint Features

Object Description
text Required Quantity text to parse, e.g. 3.2 GB
to Optional Optional target unit code to convert to
precision Optional Decimal places to round to (0-15)

Free test requests remaining: 3 of 3.


INPUT PARAMETERS

text
to
precision
API EXAMPLE RESPONSE
JSON
{
    "ok": true,
    "data": {
        "input": "3.2 GB",
        "category": "data",
        "value": 3.2,
        "unit": {
            "code": "GB",
            "name": "gigabyte (10^9 B)"
        },
        "parts": [
            {
                "value": 3.2,
                "unit": {
                    "code": "GB",
                    "name": "gigabyte (10^9 B)"
                },
                "text": "GB"
            }
        ],
        "converted": {
            "value": 2.98,
            "unit": {
                "code": "GiB",
                "name": "gibibyte (1024^3 B)"
            },
            "formatted": "2.98 GiB"
        }
    }
}
Parse a quantity string using GET — CODE SNIPPETS

curl --location --request GET 'https://zylalabs.com/api/15644/unit+conversion+and+formatting+api/42331/parse+a+quantity+string+using+get?text=3.2 GB&to=GiB&precision=3' --header 'Authorization: Bearer YOUR_API_KEY' 


    
Request
Reads strings such as "72.5kg", "3.2 GB", "-40 °F", "6.5 L/100km", "1 ½ cups", and compound values such as "5 ft 11 in", 5'11", or "2 hours and 30 minutes". Returns the value in the first unit, each part, and, when to is given, the converted value. Up to 200 characters.
Endpoint ID: 42332
POST https://zylalabs.com/api/15644/unit+conversion+and+formatting+api/42332/parse+a+quantity+string+and+optionally+convert+it
INPUT PARAMETERS

Parse a quantity string and optionally convert it — Endpoint Features

Object Description
Request Body Required Json

Free test requests remaining: 3 of 3.


INPUT PARAMETERS

API EXAMPLE RESPONSE
JSON
{
    "ok": true,
    "data": {
        "input": "5 ft 11 in",
        "category": "length",
        "value": 5.91666666666667,
        "unit": {
            "code": "ft",
            "name": "foot"
        },
        "parts": [
            {
                "value": 5,
                "unit": {
                    "code": "ft",
                    "name": "foot"
                },
                "text": "ft"
            },
            {
                "value": 11,
                "unit": {
                    "code": "in",
                    "name": "inch"
                },
                "text": "in"
            }
        ],
        "converted": {
            "value": 180.34,
            "unit": {
                "code": "cm",
                "name": "centimeter"
            },
            "formatted": "180.34 cm"
        }
    }
}
Parse a quantity string and optionally convert it — CODE SNIPPETS

curl --location --request POST 'https://zylalabs.com/api/15644/unit+conversion+and+formatting+api/42332/parse+a+quantity+string+and+optionally+convert+it' --header 'Authorization: Bearer YOUR_API_KEY' 

--data-raw '{"text":"5 ft 11 in","to":"cm"}'

    
Request
Same as the POST version, with query parameters. system may be a comma-separated list.
Endpoint ID: 42333
GET https://zylalabs.com/api/15644/unit+conversion+and+formatting+api/42333/format+a+value+in+the+best+unit+using+get
INPUT PARAMETERS

Format a value in the best unit using GET — Endpoint Features

Object Description
value Required Numeric value to format
unit Required Unit code of the value, e.g. km
system Optional Comma-separated unit systems, e.g. metric,imperial
decimals Optional Decimal places in the formatted output

Free test requests remaining: 3 of 3.


INPUT PARAMETERS

value
unit
system
decimals
API EXAMPLE RESPONSE
JSON
{
    "ok": true,
    "data": {
        "input": {
            "value": 0.0042,
            "unit": {
                "code": "km",
                "name": "kilometer"
            }
        },
        "category": "length",
        "best": {
            "system": "metric",
            "value": 4.2,
            "unit": {
                "code": "m",
                "name": "meter"
            },
            "formatted": "4.2 m"
        },
        "results": [
            {
                "system": "metric",
                "value": 4.2,
                "unit": {
                    "code": "m",
                    "name": "meter"
                },
                "formatted": "4.2 m"
            },
            {
                "system": "imperial",
                "value": 13.78,
                "unit": {
                    "code": "ft",
                    "name": "foot"
                },
                "formatted": "13.78 ft"
            }
        ],
        "note": "The best unit is the largest unit in each system where the absolute value is at least 1."
    }
}
Format a value in the best unit using GET — CODE SNIPPETS

curl --location --request GET 'https://zylalabs.com/api/15644/unit+conversion+and+formatting+api/42333/format+a+value+in+the+best+unit+using+get?value=0.0042&unit=km&system=metric,imperial&decimals=2' --header 'Authorization: Bearer YOUR_API_KEY' 


    
Request
Picks the largest unit in each unit system where the value is at least 1, for example 1536000 bytes as "1.46 MiB" (IEC) and "1.54 MB" (SI). Systems: data si, iec, siBits, iecBits; length metric, imperial; mass metric, imperial; volume metric, us, imperial; area metric, imperial; time standard; pressure metric; energy metric, electric; power metric; angle standard. Temperature, speed, and fuel economy are not scaled.
Endpoint ID: 42334
POST https://zylalabs.com/api/15644/unit+conversion+and+formatting+api/42334/format+a+value+in+the+best+human-friendly+unit
INPUT PARAMETERS

Format a value in the best human-friendly unit — Endpoint Features

Object Description
Request Body Required Json

Free test requests remaining: 3 of 3.


INPUT PARAMETERS

API EXAMPLE RESPONSE
JSON
{
    "ok": true,
    "data": {
        "input": {
            "value": 1536000,
            "unit": {
                "code": "B",
                "name": "byte"
            }
        },
        "category": "data",
        "best": {
            "system": "iec",
            "value": 1.46,
            "unit": {
                "code": "MiB",
                "name": "mebibyte (1024^2 B)"
            },
            "formatted": "1.46 MiB"
        },
        "results": [
            {
                "system": "iec",
                "value": 1.46,
                "unit": {
                    "code": "MiB",
                    "name": "mebibyte (1024^2 B)"
                },
                "formatted": "1.46 MiB"
            },
            {
                "system": "si",
                "value": 1.54,
                "unit": {
                    "code": "MB",
                    "name": "megabyte (10^6 B)"
                },
                "formatted": "1.54 MB"
            }
        ],
        "note": "The best unit is the largest unit in each system where the absolute value is at least 1."
    }
}
Format a value in the best human-friendly unit — CODE SNIPPETS

curl --location --request POST 'https://zylalabs.com/api/15644/unit+conversion+and+formatting+api/42334/format+a+value+in+the+best+human-friendly+unit' --header 'Authorization: Bearer YOUR_API_KEY' 

--data-raw '{"value":1536000,"unit":"B"}'

    

API Access Key & Authentication

After signing up, every developer is assigned a personal API access key, a unique combination of letters and digits provided to access to our API endpoint. To authenticate with the Unit Conversion and Formatting API simply include your bearer token in the Authorization header.

Headers
Header Description
Authorization Required Should be Bearer access_key. See "Your API Access Key" above when you are subscribed.

No long-term commitment. Upgrade, downgrade, or cancel anytime. Free Trial includes up to 50 requests.

Starts at
$10,000/Year


  • Custom Volume
  • Custom Rate Limit
  • Specialized Customer Support
  • Real-Time API Monitoring

Overview

Exact unit conversion for length, mass, volume, temperature, data size (MB and MiB), pressure, energy, fuel economy and more, plus batch, quantity parsing and best-unit formatting.

Unit Conversion and Formatting API FAQs

Exact SI and NIST definitions: 1 in = 2.54 cm, 1 lb = 0.45359237 kg, 1 US gallon = 3.785411784 L, 1 imperial gallon = 4.54609 L, 1 atm = 101325 Pa, 1 BTU (IT) = 1055.05585262 J, and 1 hp = 550 ft·lbf/s. Units without a fixed length, such as the average month and year, are marked exact: false in the response.

As absolute readings with offsets applied, so 100 °C = 212 °F and 0 K = -459.67 °F. Values below absolute zero return a 400. To convert a temperature difference instead, use 1 °C = 1 K = 1.8 °F.

MB, GB, and TB are SI (decimal) units: 1 MB = 1,000,000 bytes. MiB, GiB, and TiB are IEC (binary) units: 1 MiB = 1,048,576 bytes. Codes are case-sensitive where it matters: MB is megabytes and Mb or Mbit is megabits. Lowercase mb, gb, and tb are read as bytes. The format endpoint can show both, for example 1.46 MiB and 1.54 MB.

L/100km is the reciprocal of distance per volume, so the API converts through km/L instead of a fixed factor. For example, 30 mpg (US) is about 7.84 L/100km. US and imperial mpg are separate units (mpg and mpgImp). A value of 0 is rejected because it has no reciprocal.

A number followed by a unit code, symbol, or name, such as 72.5kg, 3.2 GB, -40 °F, 1,234.5 m, 1.5e3 W, or 1 ½ cups. Compound values in one category are summed, such as 5 ft 11 in, 5'11", and 2 hours and 30 minutes. Text is limited to 200 characters. Mixed categories return a 400.

By default, results are rounded to 15 significant digits to remove floating-point noise (so 1 ft is exactly 12 in). Set precision for decimal places (0-15) or significantDigits (1-17). In a batch, top-level settings apply to every item unless an item sets its own.

The batch still returns 200. Each result has ok: true with data, or ok: false with an error code and message, and the response counts succeeded and failed items. A batch can hold up to 100 items.

Categories with a natural unit ladder: data size (SI, IEC, and bits), length, mass, volume, area, time, pressure, energy (including Wh/kWh), power, and angle. It picks the largest unit where the value is at least 1. Temperature, speed, and fuel economy are not scaled; use convert for those.

General FAQs

To obtain your API key, first sign in to your account and navigate to the API you want to use. From the API's Pricing section, choose a plan and complete the subscription process. Once subscribed, return to the API page and you will see your API Access Key displayed at the top of the documentation page. You can use this key to authenticate your requests.

You can’t switch APIs during the free trial. If you subscribe to a different API, your trial will end and the new subscription will start as a paid plan.

The free trial lasts for 7 days and allows you to make up to 50 API requests.

No, the free trial is available only once, so we recommend using it on the API that interests you the most. Most of our APIs offer a free trial, but some may not include this option.

Yes. If the API offers a free trial, you will see a "Free 7-Day Trial" option in its Pricing section. The trial lasts for 7 days and allows up to 50 API requests, enabling you to evaluate the API before subscribing to a paid plan.

Zyla API Hub is like a big store for APIs, where you can find thousands of them all in one place. We also offer dedicated support and real-time monitoring of all APIs. Once you sign up, you can pick and choose which APIs you want to use. Just remember, each API needs its own subscription. But if you subscribe to multiple ones, you'll use the same key for all of them, making things easier for you.

Prices are listed in USD (United States Dollar), EUR (Euro), CAD (Canadian Dollar), AUD (Australian Dollar), and GBP (British Pound). We accept all major debit and credit cards. Our payment system uses the latest security technology and is powered by Stripe, one of the world's most reliable payment companies. If you have any trouble paying by card, just contact us at [email protected]

Additionally, if you already have an active subscription in any of these currencies (USD, EUR, CAD, AUD, GBP), that currency will remain for subsequent subscriptions. You can change the currency at any time as long as you don't have any active subscriptions.
The local currency shown on the pricing page is based on the country of your IP address and is provided for reference only. The actual prices are in USD (United States Dollar). When you make a payment, the charge will appear on your card statement in USD, even if you see the equivalent amount in your local currency on our website. This means you cannot pay directly with your local currency.
Occasionally, a bank may decline the charge due to its fraud protection settings. We suggest reaching out to your bank initially to check if they are blocking our charges. Also, you can access the Billing Portal and change the card associated to make the payment. If these does not work and you need further assistance, please contact our team at [email protected]
Prices are determined by a recurring monthly or yearly subscription, depending on the chosen plan.
API calls are deducted from your plan based on successful requests. Each plan comes with a specific number of calls that you can make per month. Only successful calls, indicated by a Status 200 response, will be counted against your total. This ensures that failed or incomplete requests do not impact your monthly quota.
Zyla API Hub works on a recurring monthly subscription system. Your billing cycle will start the day you purchase one of the paid plans, and it will renew the same day of the next month. So be aware to cancel your subscription beforehand if you want to avoid future charges.
To upgrade your current subscription plan, simply go to the pricing page of the API and select the plan you want to upgrade to. The upgrade will be instant, allowing you to immediately enjoy the features of the new plan. Please note that any remaining calls from your previous plan will not be carried over to the new plan, so be aware of this when upgrading. You will be charged the full amount of the new plan.
To check how many API calls you have left for the current month, refer to the 'X-Zyla-API-Calls-Monthly-Remaining' field in the response header. For example, if your plan allows 1,000 requests per month and you've used 100, this field in the response header will indicate 900 remaining calls.

You can monitor your API usage through the response headers included with every request:

x-zyla-api-calls-monthly-used: Shows the total number of API requests you have used during the current billing period.
x-zyla-api-calls-monthly-remaining: Shows the number of API requests you have remaining for the current billing period.

The 'X-Zyla-RateLimit-Reset' header shows the number of seconds until your rate limit resets. This tells you when your request count will start fresh. For example, if it displays 3,600, it means 3,600 seconds are left until the limit resets.

Yes, you can cancel your subscription at any time. Simply go to the Pricing section of the API you're subscribed to and click the "Unsubscribe" button.

Please note that upgrades, downgrades, and cancellations take effect immediately. Once your subscription is canceled, access to the service will end immediately, regardless of any remaining API calls in your quota.

After 7 days, you will be charged the full amount for the plan you were subscribed to during the trial. Therefore, it's important to cancel before the trial period ends. Refund requests for forgetting to cancel on time are not accepted.
When you subscribe to an API free trial, you can make up to 50 API calls. If you wish to make additional API calls beyond this limit, the API will prompt you to perform an "Start Your Paid Plan." You can find the "Start Your Paid Plan" button in your profile under Subscription -> Choose the API you are subscribed to -> Pricing tab.
You can contact us through our chat channel to receive immediate assistance. We are always online from 8 am to 5 pm (EST). If you reach us after that time, we will get back to you as soon as possible. Additionally, you can contact us via email at [email protected]

Please have a look at our Refund Policy: https://zylalabs.com/terms#refund


Related APIs