cURL
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 } ] }
Translate text between languages
POST https://api.langdex.co/v1/translations/translate
Show child attributes
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" }'
{ "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 } ] }
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} ] }
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} ] }
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": { "code": "word_not_found", "message": "No lexeme found for 'xyzabc' in language 'eng'" } }
{ "source": {...}, "translations": [], "warning": "No translations found for this sense in the target language" }