Skip to main content

Language Detection API

The language detection endpoint identifies the language of a given text and returns a confidence score. This is useful for routing text into language-specific processing pipelines before calling other Sapling APIs.

Try it out

Sample Code

curl -X POST https://api.sapling.ai/api/v1/langdetect \
-H "Content-Type: application/json" \
-d '{"key":"<api-key>", "text":"This is an English sentence."}'

Sample Response

{
"lang": "en",
"conf": 0.99
}

Request Parameters

POST to https://api.sapling.ai/api/v1/langdetect

key: String
32-character API key. Can also be supplied via the Authorization header as a bearer token; if both are provided, the key parameter takes precedence.

text: String
Text to identify the language for.

Response Parameters

The language detection response contains two fields:

  1. lang: The detected language code.
  2. conf: Confidence score for the detection result.