Skip to content

Translate a list

Use it when you already have many short strings, such as UI labels, and want one round trip.

Purpose

POST /texts translates up to 128 plain-text strings in one call and keeps their order.

When to use it

Use it when you already have many short strings, such as UI labels, and want one round trip.

Request

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

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.
textsstring[]yesnone1 to 128 strings. Each string is at most 1,037,299 characters.Plain-text strings translated in order. The response array has the same length and order.

Payload

Full request

curl -X POST "https://edge.harktranslate.com/api/v1/translator/texts" \
  -H "x-hark-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
--data-binary @- <<'JSON'
{
  "from": "en",
  "to": "vi",
  "texts": [
    "Hello",
    "Goodbye"
  ]
}
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. trans has the same length and order as texts.

200 body

{
  "trans": [
    "...",
    "..."
  ],
  "meta": {
    "quality": "auto-latency",
    "grade": "nmt",
    "degraded_segments": 0
  }
}

Common mistakes

  • More than 128 strings

    The array must contain 1 to 128 strings. Split a longer list into another request.

  • Reading trans out of order

    Index 0 in the response is index 0 in the request. Do not sort either array.