Translate
The /translate
endpoint provides the translation of any text, into 230+ languages. This endpoint uses the Google Translate API under the hood, thus, comes with its accuracy.
Method: GET
To make a request, just send a GET
or POST
request to the /translate
endpoint, with authorization header, and request body set like this:
{
"source_text": "Hello World",
"source_language": "en",
"target_language": "ja"
}
Parameters
source_text
: It is the text to be translated. It can be either a string or an array of strings.source_language
: It is the language code of the source text. It defaults toauto
target_language
: It is the language code, to which the text should be translated.
Responses
The success response would be like this, where data
contains translations
array, which contains the translated text.
{
"status": "success",
"data": {
"translations": [
{
"source_text": "Hello World",
"translation": "こんにちは世界",
"source_language": "en",
"target_language": "ja"
}
]
},
"message": "Translation has been completed successfully."
}
And if some error occurs like, when source_text
is not provided, the response would be like this:
{
"status":"error",
"error":{
"code":"INVALID_REQUEST",
"message":"'source_text' has not been provided.",
"details":"Text to be translated, that is, 'source_text' is required but missing."
}
}
Notes
This endpoint supports translation of more than 230 languages. The /supported_languages
endpoint is used to get the list of all the supported languages.