Method: detect Stay organized with collections Save and categorize content based on your preferences.
Detects the language of text within a request.
HTTP request
POST https://translation.googleapis.com/language/translate/v2/detect
The URL usesGoogle API HTTP annotation syntax.
Query parameters
| Parameters | |
|---|---|
q |
Required The input text upon which to perform language detection. Repeat this parameter to perform language detection on multiple text inputs. |
key |
A valid API key to handle requests for this API. If you are using OAuth 2.0 service account credentials (recommended), do not supply this parameter. |
Response body
If successful, the response body contains data with the following structure:
| JSON representation | |
|---|---|
{"data":{object( | |
| Fields | |
|---|---|
data |
The list of language detection responses. This list will contain a language detection response for each query (q) sent in the language detection request. |
Authorization
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/cloud-translationhttps://www.googleapis.com/auth/cloud-platform
For more information, see theAuth Guide.
DetectLanguageResponseList
A response list contains a list of separate language detection responses.
| JSON representation | |
|---|---|
{"detections":[array],} | |
| Fields | |
|---|---|
detections[] |
Language detection results for each input text piece. The detections ListValue includes the following values:
We recommend not basing any decisions or thresholds on the For example: "detections":[ [{ "language": "en", "isReliable": false, "confidence": 0.9882 }], [{ "language": "pl", "isReliable": false, "confidence": 0.5683 }]] |
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-04-30 UTC.