Vietnamese amounts to numbers API
Turn Vietnamese written or colloquial amounts into numbers: “hai triệu rưỡi”, “2tr5”, “500k”, “1 tỷ 2”, “2 củ”; batch mode and amount extraction from text.
The reverse of number-to-words for Vietnamese. The parser understands standard reading (hai nghìn không trăm hai mươi sáu, một trăm lẻ năm, ba mươi mốt, mười lăm nghìn), colloquial shortcuts (hai triệu rưỡi, trăm rưỡi, một tỷ hai = 1.2 billion, hai lăm nghìn, nửa triệu), shop and chat slang (500k, 2tr5, 1k2, 2 củ, 1 tỏi, 2 lít), Vietnamese decimal and thousands separators (1,5 triệu, 1.500.000đ) and text typed without accents (hai trieu ruoi).
Each result has the value, the currency when one is written (đồng, đ, VNĐ, $, USD) or implied by slang, the amount read back in words, a confidence score and the alternative reading when the text is ambiguous (2tr5 could literally be 2,000,005; 1.500 could be 1.5). mode=extract finds every amount inside a sentence with its character positions, handy for chat orders or bank transfer notes; texts parses up to 1,000 strings at once.
Ranges such as “2-3 triệu” are returned as two amounts, and digit sequences like “hai ba” are rejected as ambiguous instead of guessed.
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
text | query|body | string | yes | The amount (or a sentence with mode=extract). | |
mode | query|body | string | no | parse | parse: the whole text is one amount; extract: find amounts inside the text. |
texts | body | array | no | Up to 1,000 strings (batch). | |
money_only | query|body | boolean | no | false | Extract: keep only amounts with a currency, slang or a scale (nghìn, triệu…). |
Example
curl "https://apibox.io.vn/v1/vn-number-parse?mode=extract&text=C%E1%BB%8Dc%202tr5%2C%20c%C3%B2n%20l%E1%BA%A1i%20m%E1%BB%99t%20tri%E1%BB%87u%20hai%20tr%C4%83m%20ngh%C3%ACn%20%C4%91%E1%BB%93ng%2C%20ship%2030k" \
-H "Authorization: Bearer YOUR_API_KEY"const res = await fetch('https://apibox.io.vn/v1/vn-number-parse?mode=extract&text=C%E1%BB%8Dc%202tr5%2C%20c%C3%B2n%20l%E1%BA%A1i%20m%E1%BB%99t%20tri%E1%BB%87u%20hai%20tr%C4%83m%20ngh%C3%ACn%20%C4%91%E1%BB%93ng%2C%20ship%2030k', {
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/vn-number-parse?mode=extract&text=C%E1%BB%8Dc%202tr5%2C%20c%C3%B2n%20l%E1%BA%A1i%20m%E1%BB%99t%20tri%E1%BB%87u%20hai%20tr%C4%83m%20ngh%C3%ACn%20%C4%91%E1%BB%93ng%2C%20ship%2030k",
headers={"Authorization": "Bearer YOUR_API_KEY"},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/vn-number-parse?mode=extract&text=C%E1%BB%8Dc%202tr5%2C%20c%C3%B2n%20l%E1%BA%A1i%20m%E1%BB%99t%20tri%E1%BB%87u%20hai%20tr%C4%83m%20ngh%C3%ACn%20%C4%91%E1%BB%93ng%2C%20ship%2030k');
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
{
"mode": "extract",
"text": "Cọc 2tr5, còn lại một triệu hai trăm nghìn đồng, ship 30k",
"count": 3,
"amounts": [
{
"text": "2tr5",
"value": 2500000,
"currency": "VND",
"is_money": true,
"in_words": "Hai triệu năm trăm nghìn đồng",
"confidence": 0.85,
"alternatives": [
{
"value": 2000005,
"reading": "literal (the trailing number as units)"
}
],
"start": 4,
"end": 8
},
{
"text": "một triệu hai trăm nghìn đồng",
"value": 1200000,
"currency": "VND",
"is_money": true,
"in_words": "Một triệu hai trăm nghìn đồng",
"confidence": 1,
"alternatives": [],
"start": 18,
"end": 47
},
{
"text": "30k",
"value": 30000,
"currency": "VND",
"is_money": true,
"in_words": "Ba mươi nghìn đồng",
"confidence": 1,
"alternatives": [],
"start": 54,
"end": 57
}
],
"total": 3730000
}
Use cases
- Read prices typed by customers in a sales chatbot
- Parse amounts in bank transfer descriptions
- Normalise free-text budgets in real-estate search (“dưới 3 tỷ”)
- Convert speech-to-text output to numbers
FAQ
How is “2tr5” read?
As 2,500,000: digits after a unit are the next fraction (like “2 triệu 5 trăm nghìn”). The literal reading 2,000,005 is returned as an alternative.
Does it work without accents?
Yes for single amounts (“hai trieu ruoi”). In extraction mode unaccented words need a unit (trieu, nghin…) to avoid false matches.
Which slang is supported?
k / nghìn / ngàn, tr / triệu / củ, tỷ / tỉ / tỏi, lít and xị (100,000), chục, rưỡi and nửa.
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.