Language Detection API
Detect the language of a text among 80+ languages with a confidence score, scripts and candidates, including Vietnamese written without accents.
The language detection API identifies the language of a text using trigram statistics (the franc model, covering the 82 most spoken languages) and returns the ISO 639-1 and 639-3 codes, the language name in English and Vietnamese, a confidence score, whether the result is reliable, the scripts found (Latin, Han, Cyrillic, Thai…) and the next candidates.
Vietnamese gets special rules: text with tone marks is recognised with certainty, and text typed without accents (“xin chao cac ban”), which general detectors confuse with other languages, is detected from frequent Vietnamese syllables and flagged in note. Up to 100 texts can be sent at once with texts.
Very short texts (a few words) are inherently ambiguous: check reliable before acting on the result. Everything runs locally without AI models, so it is fast and free of per-token costs.
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
text | query|body | string | yes | Text (max 100,000 characters; the first 20,000 are analysed). | |
texts | body | array | no | Up to 100 texts at once. |
Example
curl "https://apibox.io.vn/v1/lang-detect?text=Xin chao cac ban, hom nay troi dep qua" \
-H "Authorization: Bearer YOUR_API_KEY"const res = await fetch('https://apibox.io.vn/v1/lang-detect?text=Xin chao cac ban, hom nay troi dep qua', {
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/lang-detect?text=Xin chao cac ban, hom nay troi dep qua",
headers={"Authorization": "Bearer YOUR_API_KEY"},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/lang-detect?text=Xin chao cac ban, hom nay troi dep qua');
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
{
"length": 38,
"language": "vi",
"iso639_3": "vie",
"name": {
"en": "Vietnamese",
"vi": "Tiếng Việt"
},
"confidence": 1,
"reliable": true,
"note": "Vietnamese written without accents (không dấu)",
"scripts": [
"Latin"
],
"candidates": [
{
"language": "vi",
"iso639_3": "vie",
"score": 1
},
"…"
]
}
Use cases
- Route support tickets and chats to the right team
- Pick the right search index or spell checker
- Tag user-generated content by language
- Detect unaccented Vietnamese to suggest adding accents
FAQ
How many languages?
About 82 (franc-min), all the major languages of the world and of South-East Asia.
Why is a short text unreliable?
One or two words do not carry enough statistics; reliable is true only from about 5 words with a clear winner.
Can it detect Vietnamese without accents?
Yes, from frequent unaccented syllables (khong, duoc, nguoi…); note says so.
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.