Detect Language API

Detect the language of the given text. The API returns a list of languages and their confidence scores. The confidence score is a value between 0 and 1, where 1 means the language was detected with 100% confidence. The API detects 99 languages, using the Apache OpenNLP language model (103 language variants folded into 99 codes).

Each entry contains the language as an ISO 639-1 code (or an ISO 639-3 code where the language has no ISO 639-1 code) and a confidence between 0 and 1. The entries are sorted by confidence, highest first, and languages with a confidence of 0.01 or less are omitted. Detection works best on a full sentence or more; for very short phrases (a few words) the confidence is low and the result is less reliable.

Supported languages (99): Afrikaans (af), Arabic (ar), Asturian (ast), Azerbaijani (az), Bashkir (ba), Belarusian (be), Bulgarian (bg), Bengali (bn), Breton (br), Bosnian (bs), Catalan (ca), Chechen (ce), Cebuano (ceb), Czech (cs), Welsh (cy), Danish (da), German (de), Greek (el), English (en), Esperanto (eo), Spanish (es), Estonian (et), Basque (eu), Persian (fa), Finnish (fi), Faroese (fo), French (fr), Western Frisian (fy), Irish (ga), Galician (gl), Swiss German (gsw), Gujarati (gu), Hebrew (he), Hindi (hi), Croatian (hr), Hungarian (hu), Armenian (hy), Indonesian (id), Icelandic (is), Italian (it), Japanese (ja), Javanese (jv), Georgian (ka), Kazakh (kk), Kannada (kn), Korean (ko), Kyrgyz (ky), Latin (la), Luxembourgish (lb), Limburgish (li), Lithuanian (lt), Latvian (lv), Malagasy (mg), Māori (mi), Minangkabau (min), Macedonian (mk), Malayalam (ml), Mongolian (mn), Marathi (mr), Malay (ms), Maltese (mt), Min Nan (nan), Norwegian Bokmål (nb), Low German (nds), Nepali (ne), Dutch (nl), Norwegian Nynorsk (nn), Occitan (oc), Punjabi (pa), Polish (pl), Pashto (ps), Portuguese (pt), Romanian (ro), Russian (ru), Sanskrit (sa), Sinhala (si), Slovak (sk), Slovenian (sl), Somali (so), Albanian (sq), Serbian (sr), Sundanese (su), Swedish (sv), Swahili (sw), Tamil (ta), Telugu (te), Tajik (tg), Thai (th), Tagalog (tl), Turkish (tr), Tatar (tt), Ukrainian (uk), Urdu (ur), Uzbek (uz), Vietnamese (vi), Volapük (vo), Waray (war), Chinese (zh), Zulu (zu).

GET
https://api.apileague.com/detect-language
Example Request and Response
GET
https://api.apileague.com/{{ examples.getDetectLanguage }}
[
    {
        "language": "de",
        "confidence": 0.83
    },
    {
        "language": "nds",
        "confidence": 0.11
    }
]
cURL
Java
Javascript
Python
Go
C#
 {{ codeCopyText }}
 {{ codeCopyText }}
 {{ codeCopyText }}
 {{ codeCopyText }}
 {{ codeCopyText }}
 {{ codeCopyText }}

Frequently Asked Questions

How many languages can be detected?

The API detects 99 languages. It uses the Apache OpenNLP language model, whose 103 language variants are folded into 99 codes: ISO 639-1, or ISO 639-3 where no two-letter code exists.

How short can the text be?

Detection works best on a full sentence or more; for very short phrases (a few words) the confidence is low and the result is less reliable.

What is the confidence score?

The confidence score is a value between 0 and 1 indicating how certain the API is about the detected language. A score of 1 represents 100% confidence.

Can it detect multiple languages in one text?

The API returns a list of potential languages with their confidence scores. If a text contains mixed languages, the API will likely return the dominant language with the highest score.

How is the Detect Language API different from the Detect Sentiment API?

The Detect Language API identifies the language of the text, while the Detect Sentiment API analyzes the emotional tone (positive or negative) of the text.

Questions? Need Help? Ask Away