Method: detect

Detects the language of text within a request.

HTTP request

POST https://translation.googleapis.com/language/translate/v2/detect

The URL uses Google API HTTP annotation syntax.

Query parameters

Parameters
q

string

Required The input text upon which to perform language detection. Repeat this parameter to perform language detection on multiple text inputs.

key

string

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(DetectLanguageResponseList)
  },
}
Fields
data

object (ListValue)

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 the following OAuth scope:

  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Auth Guide.

DetectLanguageResponseList

A response list contains a list of separate language detection responses.

JSON representation
{
  "detections": [
    array
  ],
}
Fields
detections[]

array (ListValue format)

Language detection results for each input text piece. For backward compatibility, this list must be expressed as an array of arrays, which requires using ListValue in proto3.

The detections ListValue includes the following values:

  • language (string) - The detected language.
  • isReliable (boolean) - Indicates whether the language detection result is reliable.
  • confidence (float) - The confidence of the detection result for this language.

For example:

"detections":
[
  [{
    "language": "en",
    "isReliable": false,
    "confidence": 0.9882
  }],
  [{
    "language": "pl",
    "isReliable": false,
    "confidence": 0.5683
  }]
]

Send feedback about...

Translation API