POSThttps://edge.harktranslate.com/api/v1/translator/detect-language
Request
Send JSON (Content-Type: application/json). Form-encoded bodies are also accepted. Authenticate with the x-hark-key header.
| Field | Type | Required | Default | Allowed | Description |
|---|---|---|---|---|---|
| text | string | yes | none | 1 to 1,037,299 characters. | The string to translate, or the text whose language should be identified. |
Response
Success is HTTP 200.
| Field | Type | Description |
|---|---|---|
| trust_level | number | How confident detection was. |
| source_lang_code | string | Detected language code. |
| source_lang | string | Detected language name. |
{
"trust_level": 1,
"source_lang_code": "fr",
"source_lang": "French"
}Samples
Replace YOUR_API_KEY or set HARK_API_KEY. The samples call https://edge.harktranslate.com/api/v1/translator.
Detect
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"
}
JSONconst response = await fetch("https://edge.harktranslate.com/api/v1/translator/detect-language", {
method: "POST",
headers: {
"x-hark-key": process.env.HARK_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
"text": "Bonjour"
}),
});
if (!response.ok) {
throw new Error(`Hark responded ${response.status}`);
}
console.log(await response.json());import os
import requests
response = requests.post(
"https://edge.harktranslate.com/api/v1/translator/detect-language",
headers={"x-hark-key": os.environ["HARK_API_KEY"]},
json={
"text": "Bonjour",
},
timeout=30,
)
response.raise_for_status()
print(response.json())Status codes and machine codes are listed on the error catalog, including 200, 202, 400, 401, 403, 404, 413, 429, and 503.