API Features
Standard Detection
Standard (single) language detection is performed using the languagelayer API's default detect endpoint, simply by passing your preferred query text into the API's query parameter.
Example query:
Example response:
Please note: For best results please make sure to always URL encode the contents of the
queryparameter before passing it into the API request URL.
Batch Detection
The languagelayer API also offers the capability to process multiple query texts in a single API request. To make use of this feature, simply include the API's batch endpoint and pass a series of query [] parameters into your API request URL.
The following API request contains three separate query texts at once:
- Good afternoon, sir. How are you today? (English)
- Guten Tag mein Herr, wie geht es Ihnen? (German)
- Buenos días señor, cómo está hoy? (Spanish)
Example query:
Important: This documentation is presenting API requests primarily using the HTTP
GETmethod. Please note that when making batch requests we'd highly recommend sending allquery []parameters usingPOSTinstead.
Important: For batch requests a maximum of 100 different
query []parameters has been established.
Example response:
After executing this batch request, the API will return single- or multiple-language detection results for each requested query text, in the same order they were initially specified in the API request.
Please note: Since batch detection requests combine multiple API requests into one, each requested
query []text will increment your API usage by one request.
Probability
Each language-detection JSON result includes a probability score, a numerical value (no range) indicating how well the listed language was identified from the provided text. This value is also a key ingredient for the API's Reliable Result calculation.
Please note: The more text passed into the API's
queryparameter, the more representative theprobabilityvalue becomes.
Percentage
The languagelayer API will also return a percentage JSON response object, aiming to reflect its confidence with the respective language match in a familiar and more understandable way.
Please note: The
percentagevalue also serves the purpose of indicating the confidence margin between different language matches.
Reliable Result
Finally, the API will return a reliable_result object containing true or false depending on whether or not the API is completely confident about the main language match.
Please note: The r
eliable_resultdecision is based on a variety of factors, including the length of the text, the use of language-specific words and expressions, theprobabilityvalue, and more.
Important: While a positive (true) r
eliable_resultguarantees the respective language to be a complete and reliable match, language detection results containing a negative (false) value can still be very accurate.