{
"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."
}
}
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'
{
"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
}
}
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}'
{
"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."
}
}
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'
{
"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)."
}
}
]
}
}
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"}]}'
{
"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"
}
}
}
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'
{
"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"
}
}
}
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"}'
{
"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."
}
}
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'
{
"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."
}
}
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"}'
Após se cadastrar, cada desenvolvedor recebe uma chave de acesso à API pessoal, uma combinação única de letras e dígitos para acessar nosso endpoint de API. Para autenticar com a Conversão e formatação de unidades API basta incluir seu token Bearer no cabeçalho Authorization.
| Cabeçalho | Descrição |
|---|---|
Authorization
|
Obrigatório
Deve ser Bearer access_key. Veja "Sua chave de acesso à API" acima quando você estiver inscrito.
|
Sem compromisso de longo prazo. Faça upgrade, downgrade ou cancele a qualquer momento. O teste gratuito inclui até 50 requisições.
Conversão exata de unidades de comprimento, massa, volume, temperatura, tamanho de dados (MB e MiB), pressão, energia, economia de combustível e muito mais, além de conversão em lote, análise de quantidades e formatação na melhor unidade
Definições exatas do SI e do NIST: 1 pol = 2.54 cm, 1 lb = 0.45359237 kg, 1 galão americano = 3.785411784 L, 1 galão imperial = 4.54609 L, 1 atm = 101325 Pa, 1 BTU (IT) = 1055.05585262 J, e 1 hp = 550 ft·lbf/s. Unidades sem um comprimento fixo, como o mês e o ano médios, são marcadas como exatas: falso na resposta
Como leituras absolutas com deslocamentos aplicados, portanto 100 °C = 212 °F e 0 K = -459,67 °F. Valores abaixo do zero absoluto retornam um 400. Para converter uma diferença de temperatura, use 1 °C = 1 K = 1,8 °F. .
MB, GB e TB são unidades do SI (decimais): 1 MB = 1.000.000 bytes. MiB, GiB e TiB são unidades IEC (binárias): 1 MiB = 1.048.576 bytes. Os códigos diferenciam maiúsculas de minúsculas quando isso é relevante: MB significa megabytes e Mb ou Mbit significam megabits. mb, gb e tb em minúsculas são interpretados como bytes. O endpoint de formato pode mostrar ambos, por exemplo 1,46 MiB e 1,54 MB.
L/100 km é o inverso da distância por volume, por isso a API converte por meio de km/L em vez de usar um fator fixo Por exemplo, 30 mpg (EUA) são aproximadamente 7,84 L/100 km mpg dos EUA e mpg imperial são unidades separadas (mpg e mpgImp) Um valor de 0 é rejeitado porque não tem inverso
Um número seguido de um código, símbolo ou nome de unidade, como 72,5 kg, 3,2 GB, -40 °F, 1.234,5 m, 1,5e3 W ou 1 ½ xícaras. Valores compostos de uma categoria são somados, como 5 pés e 11 polegadas, 5'11" e 2 horas e 30 minutos. O texto é limitado a 200 caracteres. Categorias mistas retornam um 400. .
Por padrão, os resultados são arredondados para 15 dígitos significativos para remover ruídos de ponto flutuante (assim, 1 pé equivale exatamente a 12 pol). Defina a precisão em casas decimais (0-15) ou significantDigits (1-17). Em um lote, as configurações de nível superior se aplicam a cada item, a menos que um item defina suas próprias configurações. .
O lote ainda retorna 200 Cada resultado tem ok: true com dados ou ok: false com um código de erro e uma mensagem e a resposta contabiliza os itens bem-sucedidos e com falha Um lote pode conter até 100 itens
Categorias com uma escala natural de unidades: tamanho de dados (SI, IEC e bits), comprimento, massa, volume, área, tempo, pressão, energia (incluindo Wh/kWh), potência e ângulo. Ele escolhe a maior unidade em que o valor seja pelo menos 1. Temperatura, velocidade e consumo de combustível não são escalados; use convert para esses casos