# Method: detect

- [HTTP request](https://docs.cloud.google.com/translate/docs/reference/rest/v2/detect#body.HTTP_TEMPLATE)
- [Query parameters](https://docs.cloud.google.com/translate/docs/reference/rest/v2/detect#body.QUERY_PARAMETERS)
- [Request body](https://docs.cloud.google.com/translate/docs/reference/rest/v2/detect#body.request_body)
- [Response body](https://docs.cloud.google.com/translate/docs/reference/rest/v2/detect#body.response_body)
  - [JSON representation](https://docs.cloud.google.com/translate/docs/reference/rest/v2/detect#body.DetectLanguageResponse.SCHEMA_REPRESENTATION)
- [Authorization](https://docs.cloud.google.com/translate/docs/reference/rest/v2/detect#body.aspect)
- [DetectLanguageResponseList](https://docs.cloud.google.com/translate/docs/reference/rest/v2/detect#DetectLanguageResponseList)
  - [JSON representation](https://docs.cloud.google.com/translate/docs/reference/rest/v2/detect#DetectLanguageResponseList.SCHEMA_REPRESENTATION)

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](https://github.com/googleapis/googleapis/blob/master/google/api/http.proto) 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(`https://docs.cloud.google.com/translate/docs/reference/rest/v2/detect#DetectLanguageResponseList`) }, } ``` |

| Fields ||
|---|---|
| `data` | ``object (`https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.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 one of the following OAuth scopes:

- `https://www.googleapis.com/auth/cloud-translation`
- `https://www.googleapis.com/auth/cloud-platform`

For more information, see the [Auth Guide](https://cloud.google.com/docs/authentication/).

## DetectLanguageResponseList

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

| JSON representation ||
|---|---|
| ``` { "detections": [ array ], } ``` |

| Fields ||
|---|---|
| `detections[]` | ``array (`https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.ListValue` format)`` Language detection results for each input text piece. The detections ListValue includes the following values: - `language (string)` - The detected language - `isReliable (boolean)` - *Deprecated* Indicates whether the language detection result is reliable - `confidence (float)` - *Deprecated* The confidence of the detection result for this language We recommend not basing any decisions or thresholds on the `isReliable` or `confidence` values. For example: ``` "detections": [ [{ "language": "en", "isReliable": false, "confidence": 0.9882 }], [{ "language": "pl", "isReliable": false, "confidence": 0.5683 }] ] ``` |