Translator - Translate
Translates text into one or more languages.
POST {Endpoint}/translate?api-version=3.0&to={to}
POST {Endpoint}/translate?api-version=3.0&from={from}&to={to}&textType={textType}&category={category}&profanityAction={profanityAction}&profanityMarker={profanityMarker}&includeAlignment={includeAlignment}&includeSentenceLength={includeSentenceLength}&suggestedFrom={suggestedFrom}&fromScript={fromScript}&toScript={toScript}
URI Parameters
Name | In | Required | Type | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Endpoint
|
path | True |
string |
Supported Cognitive Services endpoints |
||||||||||||||||||||||||||||||
api-version
|
query | True |
string |
Version of the API requested by the client. Value must be 3.0. |
||||||||||||||||||||||||||||||
to
|
query | True |
string[] |
Specifies the language of the output text. Find which languages are available to translate to by using the languages method. For example, use |
||||||||||||||||||||||||||||||
category
|
query |
string |
A string specifying the category (domain) of the translation. This parameter retrieves translations from a customized system built with Custom Translator. Default value is |
|||||||||||||||||||||||||||||||
from
|
query |
string |
Specifies the language of the input text. Find which languages are available to translate from by using the languages method. If the |
|||||||||||||||||||||||||||||||
from
|
query |
string |
Specifies the script of the input text. Supported scripts are available from the languages method |
|||||||||||||||||||||||||||||||
include
|
query |
boolean |
Specifies whether to include alignment projection from source text to translated text. Possible values are- |
|||||||||||||||||||||||||||||||
include
|
query |
boolean |
Specifies whether to include sentence boundaries for the input text and the translated text. Possible values are- |
|||||||||||||||||||||||||||||||
profanity
|
query |
string |
Specifies how profanities should be treated in translations. Possible values are: Handling ProfanityNormally the Translator service will retain profanity that is present in the source in the translation. The degree of profanity and the context that makes words profane differ between cultures, and as a result the degree of profanity in the target language may be amplified or reduced. If you want to avoid getting profanity in the translation, regardless of the presence of profanity in the source text, you can use the profanity filtering option. The option allows you to choose whether you want to see profanity deleted, whether you want to mark profanities with appropriate tags (giving you the option to add your own post-processing), or you want no action taken. The accepted values of
|
|||||||||||||||||||||||||||||||
profanity
|
query |
string |
Specifies how profanities should be marked in translations. Possible values are- |
|||||||||||||||||||||||||||||||
suggested
|
query |
string |
Specifies a fallback language if the language of the input text can't be identified. Language auto-detection is applied when the |
|||||||||||||||||||||||||||||||
text
|
query |
string |
Defines whether the text being translated is plain text or HTML text. Any HTML needs to be a well-formed, complete HTML element. Possible values are |
|||||||||||||||||||||||||||||||
to
|
query |
string[] |
Specifies the script of the translated text. Supported scripts are available from the languages method |
Request Header
Name | Required | Type | Description |
---|---|---|---|
X-ClientTraceId |
string |
A client-generated GUID to uniquely identify the request. Note that you can omit this header if you include the trace ID in the query string using a query parameter named ClientTraceId. |
Request Body
Name | Type | Description |
---|---|---|
text |
Request bodyThe body of the request is a JSON array. Each array element is a JSON object with a string property named
Response bodyA successful response is a JSON array with one result for each string in the input array. A result object includes the following properties-
|
Responses
Name | Type | Description |
---|---|---|
200 OK |
Success |
|
Other Status Codes |
Error response. |
Security
Ocp-Apim-Subscription-Key
Type:
apiKey
In:
header
Ocp-Apim-Subscription-Key
Type:
apiKey
In:
header
Ocp-Apim-Subscription-Region
Type:
apiKey
In:
header
Examples
Translate success example
Sample Request
POST https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&from=en&to=es&includeAlignment={includeAlignment}&includeSentenceLength={includeSentenceLength}&suggestedFrom={suggestedFrom}
[
{
"Text": "I would really like to drive your car."
}
]
Sample Response
[
{
"translations": [
{
"text": "Realmente me gustaría conducir su coche.",
"to": "es"
}
]
}
]
Definitions
Name | Description |
---|---|
Detected |
|
Error | |
Error |
|
Translate |
Example of a successful translate request, including all optional parameters. |
Translate |
Text needed for a translate request |
Translations |
DetectedLanguage
Name | Type | Description |
---|---|---|
language |
string |
|
score |
integer |
Error
Name | Type | Description |
---|---|---|
code |
string |
|
message |
string |
ErrorMessage
Name | Type | Description |
---|---|---|
error |
TranslateResultAll
Example of a successful translate request, including all optional parameters.
Name | Type | Description |
---|---|---|
detectedLanguage | ||
translations |
TranslateTextInput
Text needed for a translate request
Name | Type | Description |
---|---|---|
text |
string |
Translations
Name | Type | Description |
---|---|---|
code |
string |
|
dir |
string |
|
name |
string |
|
nativeName |
string |