Unit Converter API
Convert length, mass, area, volume, speed, data size, pressure, energy, power, time and temperature, including Vietnamese units (lượng, chỉ, sào, mẫu, công).
The unit conversion API converts a value between about 150 units in 11 categories: length, mass, area, volume, speed, data size (decimal KB/MB and binary KiB/MiB, bits and bytes), pressure, energy, power, time and temperature. value=100&from=km/h&to=mph returns the result and a ready-made text; without to it converts into every unit of the category, and without parameters it lists all units and their aliases.
Traditional Vietnamese units are included with their usual modern values: gold in lượng / cây (37.5 g), chỉ (3.75 g) and phân; mass in lạng (100 g), yến, tạ and tấn; land in sào and mẫu Bắc Bộ (360 / 3,600 m²) and Trung Bộ (497 / 4,970 m²), công đất (1,000 m², or 1,296 m² for the “tầm lớn”) and thước; plus colloquial ly, phân, tấc, thước, cây số, khối and số điện (kWh).
Unit names are matched without accents or case where it is unambiguous (luong, Lượng), and the category is chosen from both units, so phân means a centimetre next to m and a tenth of a chỉ next to g. Results are rounded to precision significant digits (default 10).
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
value | body|query | number | no | 1 | The value to convert. |
from | body|query | string | yes | Source unit, e.g. km, lượng, sào, GiB, F. | |
to | body|query | string | no | Target unit (empty: every unit of the category). | |
precision | body|query | number | no | 10 | Significant digits (1–15). |
Example
curl "https://apibox.io.vn/v1/unit-convert?value=2&from=lượng&to=g" \
-H "Authorization: Bearer YOUR_API_KEY"const res = await fetch('https://apibox.io.vn/v1/unit-convert?value=2&from=lượng&to=g', {
method: 'GET',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
},
});
const data = await res.json();
console.log(data);import requests
res = requests.get(
"https://apibox.io.vn/v1/unit-convert?value=2&from=lượng&to=g",
headers={"Authorization": "Bearer YOUR_API_KEY"},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/unit-convert?value=2&from=lượng&to=g');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY'],
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));Response
{
"value": 2,
"from": {
"unit": "lượng",
"name": "lượng / cây vàng (37.5 g)"
},
"to": {
"unit": "g",
"name": "gram"
},
"category": "mass",
"result": 75,
"text": "2 lượng = 75 g"
}
Use cases
- Gold price calculators (lượng, chỉ ↔ gram, troy ounce)
- Real-estate and farming apps converting sào, mẫu, công to m²
- Recipe, travel and engineering converters
- Normalise units in imported data
FAQ
How big is a sào?
It depends on the region: sào Bắc Bộ = 360 m², sào Trung Bộ = 497 m². In the South land is measured in công (1,000 m²; công tầm lớn 1,296 m²) and mẫu = 1 ha. Use the explicit names (sào Trung Bộ) to choose.
Is 1 GB 1000 or 1024 MB?
GB, MB, KB are decimal (1 GB = 1000 MB); GiB, MiB, KiB are binary (1 GiB = 1024 MiB). Bits use kbit / Mbit / Gbit.
How much is one lượng of gold?
1 lượng (cây) = 10 chỉ = 37.5 g ≈ 1.2057 troy ounces.
Related APIs
Text Diff
Compare two texts by lines, words, characters, sentences or JSON and get the changes, a similarity score and a unified diff patch.
a-bSlugify
Turn titles into clean URL slugs: accents removed (Vietnamese đ included), custom separator, optional case keeping and maximum length.
123Text Statistics
Count words, characters, sentences, paragraphs and lines, estimate reading and speaking time, and list the most frequent words of a text.