Language Detection
Detect the language of any text and receive the language name, ISO 639-1 code, and a confidence score.
Overview
Use Cases
- Routing user messages to the correct language support team
- Auto-translating user-generated content
- Filtering content by language in multilingual platforms
- Preprocessing text for NLP pipelines
Features
Supports 75 languages
Returns ISO 639-1 language code
Provides a confidence score between 0.0 and 1.0
Works on short phrases and full sentences
API Endpoints
Detect Language
Identifies the language of the provided text and returns the language name, ISO 639-1 code, and confidence score.
POST
https://api.requiems.xyz/v1/ai/detect-language
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| text | string |
Required | The text whose language should be detected. |
Try it out
Live DemoRequest
The text whose language should be detected.
Sending request...
Response Fields
| Field | Type | Description |
|---|---|---|
| language | string |
Full name of the detected language (e.g. French, English, Spanish) |
| code | string |
ISO 639-1 two-letter language code (e.g. fr, en, es). Empty string when detection is unreliable. |
| confidence | float |
Confidence score between 0.0 and 1.0. 0.0 is returned when the language cannot be reliably detected. |
Code Examples
curl -X POST https://api.requiems.xyz/v1/ai/detect-language \
-H "requiems-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Bonjour, comment Γ§a va?"}'
import requests
url = "https://api.requiems.xyz/v1/ai/detect-language"
headers = {
"requiems-api-key": "YOUR_API_KEY",
"Content-Type": "application/json"
}
payload = {"text": "Bonjour, comment Γ§a va?"}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
const response = await fetch('https://api.requiems.xyz/v1/ai/detect-language', {
method: 'POST',
headers: {
'requiems-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({ text: 'Bonjour, comment Γ§a va?' })
});
const data = await response.json();
console.log(data.data.language);
console.log(data.data.code);
console.log(data.data.confidence);
require 'net/http'
require 'json'
uri = URI('https://api.requiems.xyz/v1/ai/detect-language')
request = Net::HTTP::Post.new(uri)
request['requiems-api-key'] = 'YOUR_API_KEY'
request['Content-Type'] = 'application/json'
request.body = { text: 'Bonjour, comment Γ§a va?' }.to_json
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
data = JSON.parse(response.body)
puts data['data']['language']
puts data['data']['code']
puts data['data']['confidence']
Error Responses
validation_failed
The text field is missing or empty.
bad_request
The request body is missing or malformed.
internal_error
Unexpected server error.
Frequently Asked Questions
The endpoint supports 75 languages including English, French, Spanish, German, Italian, Portuguese, Dutch, Russian, Chinese, Japanese, Arabic, and many more.
A confidence of 0.0 means the language could not be reliably detected. This can happen with very short or ambiguous input such as a single common word that exists in multiple languages.
It is a standardised two-letter code identifying a language (e.g. "en" for English, "fr" for French, "es" for Spanish). An empty string is returned when detection is unreliable.