Detect Language

The /detect_language endpoint returns detects the language of any text. It uses Google Translate API alongside other APIs to provide the best possible detection service.

Method: POST

To make a request, send the required parameters with the authorization header, to the /detect_language via the POST method.

Parameters

This accepts only one parameter, which is text.

  • text is the text whose language is to be detected.

Responses

In a successful response, the data object contains detections array, which contains all the possible language candidates, in the decreasing order of confidence:

{
  "status": "success",
  "data": {
    "results": [
      {
        "source_text": "Cats are domestic animals",
        "detections": [
          {
            "language": "en",
            "confidence": 13.78,
            "is_reliable": true
          }
        ]
      }
    ]
  },
  "message": "Language detection was successful."
}

And if error occurs, like not providing the text parameter in the request, the structure of the error response is as follows:

{
  "status": "error",
  "error": {
    "code": "MISSING_PARAMETER",
    "message": "'text' parameter is required and must be a non-empty string.",
    "details": "Ensure the request includes a valid 'text' field with content."
  }
}

Notes

You can get the list of all supported languages, and their ISO codes by the /supported_languages endpoint.