Skip to content

Translate one string

Use it for a title, a message, or any single string that is not HTML.

Purpose

POST /text translates one plain-text string and returns it as trans.

When to use it

Use it for a title, a message, or any single string that is not HTML.

Request

POSThttps://edge.harktranslate.com/api/v1/translator/text

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

Request fields
FieldTypeRequiredDefaultAllowedDescription
fromstringyesnoneA supported language code. from also accepts auto.Source language code. The value auto asks the service to detect the source.
tostringyesnoneA supported language code. from also accepts auto.Language code to translate into.
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/text" \
  -H "x-hark-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
--data-binary @- <<'JSON'
{
  "from": "en",
  "to": "vi",
  "text": "Hello"
}
JSON

Success

HTTP 200. Strings written as ... are the response shape, not a captured translation. meta.quality is what you asked, meta.grade is what served, and meta.degraded_segments counts protected parts that could not be restored.

200 body

{
  "trans": "...",
  "source_language_code": "en",
  "source_language": "English",
  "trust_level": 1,
  "dict": null,
  "meta": {
    "quality": "auto-latency",
    "grade": "llm",
    "degraded_segments": 0
  }
}

Common mistakes

  • HTML in the text field

    Tags in text are translated as characters. Send markup to POST /html.

  • A header other than x-hark-key

    The direct key is the x-hark-key header. A missing or wrong header is rejected before translation.