POST
/
v1
/
translation
curl --request POST \
  --url https://api.writer.com/v1/translation \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "palmyra-translate",
  "source_language_code": "en",
  "target_language_code": "es",
  "text": "Hello, world!",
  "formality": true,
  "length_control": true,
  "mask_profanity": true
}'
{
  "data": "¡Hola, mundo!"
}

The Translation API allows you to translate text from one language to another. See Language support for a list of supported languages.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your Writer API key.

Body

application/json
model
enum<string>
required

The model to use for translation.

Available options:
palmyra-translate
source_language_code
string
required

The ISO-639-1 language code of the original text to translate. For example, en for English, zh for Chinese, fr for French, es for Spanish. If the language has a variant, the code appends the two-digit ISO-3166 country code. For example, Mexican Spanish is es-MX. See the list of supported languages and language codes.

target_language_code
string
required

The ISO-639-1 language code of the target language for the translation. For example, en for English, zh for Chinese, fr for French, es for Spanish. If the language has a variant, the code appends the two-digit ISO-3166 country code. For example, Mexican Spanish is es-MX. See the list of supported languages and language codes.

text
string
required

The text to translate. Maximum of 100,000 words.

formality
boolean
required

Whether to use formal or informal language in the translation. See the list of languages that support formality. If the language does not support formality, this parameter is ignored.

length_control
boolean
required

Whether to control the length of the translated text. See the list of languages that support length control. If the language does not support length control, this parameter is ignored.

mask_profanity
boolean
required

Whether to mask profane words in the translated text. See the list of languages that do not support profanity masking. If the language does not support profanity masking, this parameter is ignored.

Response

200 - application/json
Successful response
data
string
required

The result of the translation.

Was this page helpful?