Skip to main content
POST
/
v1
/
translations
/
translate
Translate
curl --request POST \
  --url https://api.example.com/v1/translations/translate \
  --header 'Content-Type: application/json' \
  --data '
{
  "text": "<string>",
  "source_lang": "<string>",
  "target_lang": "<string>",
  "limit": 123,
  "sense_hint": "<string>",
  "context": "<string>"
}
'
{
  "source": {
    "text": "<string>",
    "language": "<string>",
    "lexeme_id": 123,
    "detected_senses": [
      {}
    ]
  },
  "translations": [
    {
      "lemma": "<string>",
      "language": "<string>",
      "pos": "<string>",
      "confidence": 123,
      "lexeme_id": 123
    }
  ]
}

Request

POST https://api.langdex.co/v1/translations/translate

Request Body

text
string
required
Word or phrase to translate
source_lang
string
required
Source language ISO 639-3 code
target_lang
string
required
Target language ISO 639-3 code (or comma-separated list)
limit
integer
default:"5"
Maximum translations per target language
sense_hint
string
Hint to disambiguate word sense
context
string
Sentence context for automatic disambiguation

Response

source
object
Source word analysis
translations
array
Array of translations

Examples

Basic translation

curl -X POST "https://api.langdex.co/v1/translations/translate" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "water",
    "source_lang": "eng",
    "target_lang": "jpn"
  }'

Response

{
  "source": {
    "text": "water",
    "language": "eng",
    "lexeme_id": 12345,
    "detected_senses": [
      {"sense_id": 111, "gloss": "liquid H2O", "confidence": 0.95},
      {"sense_id": 112, "gloss": "body of water", "confidence": 0.05}
    ]
  },
  "translations": [
    {
      "lemma": "水",
      "reading": "みず",
      "language": "jpn",
      "pos": "noun",
      "confidence": 0.98,
      "lexeme_id": 56789
    },
    {
      "lemma": "お水",
      "reading": "おみず",
      "language": "jpn",
      "pos": "noun",
      "confidence": 0.85,
      "lexeme_id": 56790
    }
  ]
}

Multiple target languages

curl -X POST "https://api.langdex.co/v1/translations/translate" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "text": "water",
    "source_lang": "eng",
    "target_lang": "jpn,zho,kor,deu,fra"
  }'
{
  "source": {...},
  "translations": [
    {"lemma": "水", "language": "jpn", "confidence": 0.98},
    {"lemma": "水", "language": "zho", "confidence": 0.97},
    {"lemma": "물", "language": "kor", "confidence": 0.96},
    {"lemma": "Wasser", "language": "deu", "confidence": 0.99},
    {"lemma": "eau", "language": "fra", "confidence": 0.98}
  ]
}

Sense disambiguation with hint

curl -X POST "https://api.langdex.co/v1/translations/translate" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "text": "bank",
    "source_lang": "eng",
    "target_lang": "fra",
    "sense_hint": "financial institution"
  }'
{
  "source": {
    "text": "bank",
    "detected_senses": [
      {"sense_id": 500, "gloss": "financial institution", "confidence": 1.0}
    ]
  },
  "translations": [
    {"lemma": "banque", "confidence": 0.99}
  ]
}

Context-based disambiguation

curl -X POST "https://api.langdex.co/v1/translations/translate" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "text": "bank",
    "source_lang": "eng",
    "target_lang": "fra",
    "context": "I walked along the river bank"
  }'
{
  "source": {
    "text": "bank",
    "detected_senses": [
      {"sense_id": 501, "gloss": "side of a river", "confidence": 0.92}
    ]
  },
  "translations": [
    {"lemma": "rive", "confidence": 0.95},
    {"lemma": "berge", "confidence": 0.88}
  ]
}

Error Responses

Unknown word

{
  "error": {
    "code": "word_not_found",
    "message": "No lexeme found for 'xyzabc' in language 'eng'"
  }
}

No translations available

{
  "source": {...},
  "translations": [],
  "warning": "No translations found for this sense in the target language"
}