Skip to content

Detect language

Use it before you choose a from code, or when you only need the language of a string.

Purpose

POST /detect-language names the language of one string. It does not translate.

When to use it

Use it before you choose a from code, or when you only need the language of a string.

Request

POSThttps://edge.harktranslate.com/api/v1/translator/detect-language

Send Content-Type: application/json and authenticate with the x-hark-key header.

Request fields
FieldTypeRequiredDefaultAllowedDescription
textstringyesnone1 to 1,037,299 characters.The string to translate, or the text whose language should be identified.

Payload

Full request

curl -X POST "https://edge.harktranslate.com/api/v1/translator/detect-language" \
  -H "x-hark-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
--data-binary @- <<'JSON'
{
  "text": "Bonjour"
}
JSON

Success

HTTP 200. This route has no meta block: it does not report quality, grade, or degraded_segments, because it does not translate.

200 body

{
  "trust_level": 1,
  "source_lang_code": "fr",
  "source_lang": "French"
}

Common mistakes

  • Sending from, to, or quality

    The body is one field, text. Translate options belong on /text, /texts, /json, or /html.

  • An empty string

    text must be 1 to 1,037,299 characters.