You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/ai-services/translator/reference/rest-api-guide.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,13 +8,13 @@ manager: nitinme
8
8
ms.service: cognitive-services
9
9
ms.subservice: translator-text
10
10
ms.topic: reference
11
-
ms.date: 07/18/2023
11
+
ms.date: 09/18/2023
12
12
ms.author: lajanuar
13
13
---
14
14
15
15
# Text Translation REST API
16
16
17
-
Text Translation is a cloud-based feature of the Azure AI Translator service and is part of the Azure AI service family of REST APIs. The Text Translation API translates text between language pairs across all [supported languages and dialects](../../language-support.md). The available methods are listed in the table below:
17
+
Text Translation is a cloud-based feature of the Azure AI Translator service and is part of the Azure AI service family of REST APIs. The Text Translation API translates text between language pairs across all [supported languages and dialects](../../language-support.md). The available methods are listed in the following table:
_See_[**Virtual Network Support**](v3-0-reference.md#virtual-network-support) for Translator service selected network and private endpoint configuration and support.
30
+
28
31
## Request parameters
29
32
30
33
Request parameters passed on the query string are:
31
34
32
35
| Query Parameter | Description |
33
36
| -------| ----------- |
34
37
| api-version <imgwidth=200/> |**Required query parameter**.<br/>Version of the API requested by the client. Value must be `3.0`. |
35
-
| language |**Optional query parameter**.<br/>Language tag identifying the language of the input text. If a code isn't specified, automatic language detection will be applied. |
36
-
| script |**Optional query parameter**.<br/>Script tag identifying the script used by the input text. If a script isn't specified, the default script of the language will be assumed. |
38
+
| language |**Optional query parameter**.<br/>Language tag identifying the language of the input text. If a code isn't specified, automatic language detection is applied. |
39
+
| script |**Optional query parameter**.<br/>Script tag identifying the script used by the input text. If a script isn't specified, the default script of the language is assumed. |
| Content-Type |**Required request header**.<br/>Specifies the content type of the payload. Possible values are: `application/json`. |
44
-
| Content-Length |**Required request header**.<br/>The length of the request body. |
45
-
| X-ClientTraceId |**Optional**.<br/>A client-generated GUID to uniquely identify the request. You can omit this header if you include the trace ID in the query string using a query parameter named `ClientTraceId`. |
47
+
| Content-Length |**Required request header**.<br/>The length of the request body. |
48
+
| X-ClientTraceId |**Optional**.<br/>A client-generated GUID to uniquely identify the request. You can omit this header if you include the trace ID in the query string using a query parameter named `ClientTraceId`. |
46
49
47
50
## Request body
48
51
@@ -59,21 +62,21 @@ The following limitations apply:
59
62
* The array can have at most 100 elements.
60
63
* The text value of an array element can't exceed 50,000 characters including spaces.
61
64
* The entire text included in the request can't exceed 50,000 characters including spaces.
62
-
* If the `language` query parameter is specified, then all array elements must be in the same language. Otherwise, language auto-detection is applied to each array element independently.
65
+
* If the `language` query parameter is specified, then all array elements must be in the same language. Otherwise, language autodetection is applied to each array element independently.
63
66
64
67
## Response body
65
68
66
69
A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties:
67
70
68
-
*`sentLen`: An array of integers representing the lengths of the sentences in the text element. The length of the array is the number of sentences, and the values are the length of each sentence.
71
+
*`sentLen`: An array of integers representing the lengths of the sentences in the text element. The length of the array is the number of sentences, and the values are the length of each sentence.
69
72
70
73
*`detectedLanguage`: An object describing the detected language through the following properties:
71
74
72
75
*`language`: Code of the detected language.
73
76
74
77
*`score`: A float value indicating the confidence in the result. The score is between zero (0) and one (1.0). A low score (<= 0.4) indicates a low confidence.
75
78
76
-
The `detectedLanguage` property is only present in the result object when language auto-detection is requested.
79
+
The `detectedLanguage` property is only present in the result object when language autodetection is requested.
77
80
78
81
An example JSON response is:
79
82
@@ -95,57 +98,30 @@ An example JSON response is:
95
98
96
99
## Response headers
97
100
98
-
<tablewidth="100%">
99
-
<thwidth="20%">Headers</th>
100
-
<th>Description</th>
101
-
<tr>
102
-
<td>X-RequestId</td>
103
-
<td>Value generated by the service to identify the request. It's used for troubleshooting purposes.</td>
104
-
</tr>
105
-
</table>
101
+
|Headers|Description|
102
+
|--- |--- |
103
+
|X-RequestId|Value generated by the service to identify the request. It's used for troubleshooting purposes.|
106
104
107
105
## Response status codes
108
106
109
-
The following are the possible HTTP status codes that a request returns.
110
-
111
-
<tablewidth="100%">
112
-
<thwidth="20%">Status Code</th>
113
-
<th>Description</th>
114
-
<tr>
115
-
<td>200</td>
116
-
<td>Success.</td>
117
-
</tr>
118
-
<tr>
119
-
<td>400</td>
120
-
<td>One of the query parameters is missing or not valid. Correct request parameters before retrying.</td>
121
-
</tr>
122
-
<tr>
123
-
<td>401</td>
124
-
<td>The request couldn't be authenticated. Check that credentials are specified and valid.</td>
125
-
</tr>
126
-
<tr>
127
-
<td>403</td>
128
-
<td>The request isn't authorized. Check the details error message. This response code often indicates that all free translations provided with a trial subscription have been used up.</td>
129
-
</tr>
130
-
<tr>
131
-
<td>429</td>
132
-
<td>The server rejected the request because the client has exceeded request limits.</td>
133
-
</tr>
134
-
<tr>
135
-
<td>500</td>
136
-
<td>An unexpected error occurred. If the error persists, report it with: date and time of the failure, request identifier from response header `X-RequestId`, and client identifier from request header `X-ClientTraceId`.</td>
137
-
</tr>
138
-
<tr>
139
-
<td>503</td>
140
-
<td>Server temporarily unavailable. Retry the request. If the error persists, report it with: date and time of the failure, request identifier from response header `X-RequestId`, and client identifier from request header `X-ClientTraceId`.</td>
141
-
</tr>
142
-
</table>
143
-
144
-
If an error occurs, the request will also return a JSON error response. The error code is a 6-digit number combining the 3-digit HTTP status code followed by a 3-digit number to further categorize the error. Common error codes can be found on the [v3 Translator reference page](./v3-0-reference.md#errors).
107
+
The following are the possible HTTP status codes that a request returns.
108
+
109
+
|Status Code|Description|
110
+
|--- |--- |
111
+
|200|Success.|
112
+
|400|One of the query parameters is missing or not valid. Correct request parameters before retrying.|
113
+
|401|The request couldn't be authenticated. Check that credentials are specified and valid.|
114
+
|403|The request isn't authorized. Check the details error message. This response code often indicates that all free translations provided with a trial subscription have been used up.|
115
+
|429|The server rejected the request because the client has exceeded request limits.|
116
+
|500|An unexpected error occurred. If the error persists, report it with: date and time of the failure, request identifier from response header `X-RequestId`, and client identifier from request header `X-ClientTraceId`.|
117
+
|503|Server temporarily unavailable. Retry the request. If the error persists, report it with: date and time of the failure, request identifier from response header `X-RequestId`, and client identifier from request header `X-ClientTraceId`.|
118
+
119
+
120
+
If an error occurs, the request returns a JSON error response. The error code is a 6-digit number combining the 3-digit HTTP status code followed by a 3-digit number to further categorize the error. Common error codes can be found on the [v3 Translator reference page](./v3-0-reference.md#errors).
145
121
146
122
## Examples
147
123
148
-
The following example shows how to obtain sentence boundaries for a single sentence. The language of the sentence is automatically detected by the service.
124
+
The following example shows how to obtain sentence boundaries for a single sentence. The service automatically detects the sentence language.
149
125
150
126
```curl
151
127
curl -X POST "https://api.cognitive.microsofttranslator.com/breaksentence?api-version=3.0" -H "Ocp-Apim-Subscription-Key: <client-secret>" -H "Content-Type: application/json" -d "[{'Text':'How are you? I am fine. What did you do today?'}]"
_See_[**Virtual Network Support**](v3-0-reference.md#virtual-network-support) for Translator service selected network and private endpoint configuration and support.
31
+
28
32
## Request parameters
29
33
30
34
Request parameters passed on the query string are:
31
35
32
36
| Query parameter | Description |
33
37
| --- | --- |
34
-
| api-version |*Required parameter*.<br/>Version of the API requested by the client. Value must be `3.0`. |
38
+
| api-version |*Required parameter*.<br>Version of the API requested by the client. Value must be `3.0`. |
| Content-Type |*Required request header*.<br/>Specifies the content type of the payload. Possible values are: `application/json`. |
42
-
| Content-Length |*Required request header*.<br/>The length of the request body. |
43
-
| X-ClientTraceId |*Optional*.<br/>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`. |
| Content-Type |*Required request header*.<br>Specifies the content type of the payload. Possible values are: `application/json`. |
46
+
| Content-Length |*Required request header*.<br>The length of the request body. |
47
+
| X-ClientTraceId |*Optional*.<br>A client-generated GUID to uniquely identify the request. You can omit this header if you include the trace ID in the query string using a query parameter named `ClientTraceId`. |
44
48
45
49
## Request body
46
50
47
-
The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`. Language detection is applied to the value of the `Text` property. The language auto-detection works better with longer input text. A sample request body looks like that:
51
+
The body of the request is a JSON array. Each array element is a JSON object with a string property named `Text`. Language detection is applied to the value of the `Text` property. The language autodetection works better with longer input text. A sample request body looks like that:
48
52
49
53
```json
50
54
[
@@ -55,21 +59,21 @@ The body of the request is a JSON array. Each array element is a JSON object wit
55
59
The following limitations apply:
56
60
57
61
* The array can have at most 100 elements.
58
-
* The entire text included in the request cannot exceed 50,000 characters including spaces.
62
+
* The entire text included in the request can't exceed 50,000 characters including spaces.
59
63
60
64
## Response body
61
65
62
66
A successful response is a JSON array with one result for each string in the input array. A result object includes the following properties:
63
67
64
-
*`language`: Code of the detected language.
68
+
*`language`: Code of the detected language.
69
+
70
+
*`score`: A float value indicating the confidence in the result. The score is between zero and one and a low score indicates a low confidence.
65
71
66
-
*`score`: A float value indicating the confidence in the result. The score is between zero and one and a low score indicates a low confidence.
72
+
*`isTranslationSupported`: A boolean value that is true if the detected language is one of the languages supported for text translation.
67
73
68
-
*`isTranslationSupported`: A boolean value which is true if the detected language is one of the languages supported for text translation.
74
+
*`isTransliterationSupported`: A boolean value that is true if the detected language is one of the languages supported for transliteration.
69
75
70
-
*`isTransliterationSupported`: A boolean value which is true if the detected language is one of the languages supported for transliteration.
71
-
72
-
*`alternatives`: An array of other possible languages. Each element of the array is another object with the same properties listed above: `language`, `score`, `isTranslationSupported` and `isTransliterationSupported`.
76
+
*`alternatives`: An array of other possible languages. Each element of the array is another object the following properties: `language`, `score`, `isTranslationSupported` and `isTransliterationSupported`.
73
77
74
78
An example JSON response is:
75
79
@@ -95,23 +99,23 @@ An example JSON response is:
95
99
96
100
| Headers | Description |
97
101
| --- | --- |
98
-
| X-RequestId | Value generated by the service to identify the request. It is used for troubleshooting purposes. |
102
+
| X-RequestId | Value generated by the service to identify the request. It's used for troubleshooting purposes. |
99
103
100
104
## Response status codes
101
105
102
-
The following are the possible HTTP status codes that a request returns.
106
+
The following are the possible HTTP status codes that a request returns.
103
107
104
108
| Status Code | Description |
105
109
| --- | --- |
106
110
| 200 | Success. |
107
111
| 400 | One of the query parameters is missing or not valid. Correct request parameters before retrying. |
108
-
| 401 | The request could not be authenticated. Check that credentials are specified and valid. |
109
-
| 403 | The request is not authorized. Check the details error message. This often indicates that all free translations provided with a trial subscription have been used up. |
112
+
| 401 | The request couldn't be authenticated. Check that credentials are specified and valid. |
113
+
| 403 | The request isn't authorized. Check the details error message. This code often indicates that all free translations provided with a trial subscription have been used up. |
110
114
| 429 | The server rejected the request because the client has exceeded request limits. |
111
115
| 500 | An unexpected error occurred. If the error persists, report it with: date and time of the failure, request identifier from response header `X-RequestId`, and client identifier from request header `X-ClientTraceId`. |
112
116
| 503 | Server temporarily unavailable. Retry the request. If the error persists, report it with: date and time of the failure, request identifier from response header `X-RequestId`, and client identifier from request header `X-ClientTraceId`. |
113
117
114
-
If an error occurs, the request will also return a JSON error response. The error code is a 6-digit number combining the 3-digit HTTP status code followed by a 3-digit number to further categorize the error. Common error codes can be found on the [v3 Translator reference page](./v3-0-reference.md#errors).
118
+
If an error occurs, the request returns a JSON error response. The error code is a 6-digit number combining the 3-digit HTTP status code followed by a 3-digit number to further categorize the error. Common error codes can be found on the [v3 Translator reference page](./v3-0-reference.md#errors).
0 commit comments