├── README.md └── code-examples ├── jquery-ajax.md └── php-curl.md /README.md: -------------------------------------------------------------------------------- 1 | Stay up to date by following [@apilayernet](https://twitter.com/apilayernet) on Twitter. 2 | _________ 3 | 4 | # languagelayer API 5 | 6 | Languagelayer is a simple and powerful REST API built to efficiently match text of any length to its corresponding language, cross-referencing single words, expressions and grammatical constructions, as well as taking into account any existing accents, dialects and other linguistic deviations. 7 | 8 | ## Powered by Artificial Intelligence 9 | 10 | The languagelayer API relies on an ever-advancing, powerful and AI-based (Artificial Intelligence) detection algorithm, which increases in complexity and performance with each language detection API request performed. Only this way the languagelayer service can be capable of processing over 170 different languages & accents worldwide. 11 | 12 | In spite of its complexity behind the curtains, our language detection API continuously manages to stand out due to its easy-to-use REST interface, simple JSON response format, quick response time and low bandwidth consumption. 13 | 14 | [Sign up for for free](https://languagelayer.com/product) to get instant API Access. 15 | 16 | ## Features & Integration 17 | 18 | The main API Functionalities are: 19 | 20 | * **Standard Detection**: 21 | Detect any of 173 languages simply by passing in your URL encoded query text into the API's request URL. 22 | 23 | * **Batch Detection**: 24 | Use the batch language detection endpoint to request the API to identify a series of query texts at once. 25 | 26 | * **Probability Score**: 27 | Each language match comes with a probability score based on how well the respective language was identified. 28 | 29 | * **Confidence Percentage**: 30 | Responses also include a confidence percentage indicating the API's level of confidence about the detection. 31 | 32 | * **Reliable Result**: 33 | JSON response object indicating whether or not the API is completely confident about the detection result. 34 | 35 | * **and more ...**: 36 | JSON Formatting, JSONP Callbacks, Access-Control (CORS) headers, HTTPS Encryption, and more. 37 | 38 | [Sign up for the Free Plan](https://languagelayer.com/product) to get your API Access Key. 39 | 40 | ## In-depth Documentation 41 | 42 | Interactive example queries, code examples (including PHP/CURL and jQuery.ajax) and integration guides are available at [languagelayer.com/documentation](https://languagelayer.com/documentation). 43 | 44 | ## Customer Support 45 | Need any assistance? [Get in touch with Customer Support](mailto:support@apilayer.net?subject=[languagelayer]). 46 | 47 | ## Legal 48 | 49 | All usage of the languagelayer website, API, and services is subject to the [languagelayer Terms & Conditions](https://languagelayer.com/terms) and all annexed legal documents and agreements. 50 | -------------------------------------------------------------------------------- /code-examples/jquery-ajax.md: -------------------------------------------------------------------------------- 1 | # Language Examples 2 | 3 | ## JavaScript (jQuery.ajax) 4 | 5 | ### Standard language detection (GET): 6 | 7 | ```javascript 8 | // set endpoint and your access key 9 | var access_key = 'YOUR_ACCESS_KEY'; 10 | var query = 'Hello my friend, how are you?'; 11 | 12 | // AJAX call 13 | $.ajax({ 14 | url: 'http://apilayer.net/api/detect?access_key=' + access_key + '&query=' + encodeURIComponent(query), 15 | dataType: 'jsonp', 16 | success: function(json) { 17 | 18 | // Access and use your preferred validation result objects 19 | console.log(json.success); 20 | 21 | } 22 | }); 23 | ``` 24 | 25 | -------------------------------------------------------------------------------- /code-examples/php-curl.md: -------------------------------------------------------------------------------- 1 | # Language Examples 2 | 3 | ## PHP (CURL) 4 | 5 | ### Standard language detection in PHP (GET): 6 | 7 | ```php 8 | // set API Access Key 9 | $access_key = 'YOUR_ACCESS_KEY'; 10 | 11 | // set query text 12 | $query = 'Hello my friend, how are you today?'; 13 | 14 | // Initialize CURL: 15 | $ch = curl_init('http://apilayer.net/api/detect?access_key='.$access_key.'&query='.$query.''); 16 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 17 | 18 | // Store the data: 19 | $json = curl_exec($ch); 20 | curl_close($ch); 21 | 22 | // Decode JSON response and store array: 23 | $detection_result = json_decode($json, true); 24 | ``` 25 | 26 | ### Batch language detection in PHP (POST): 27 | 28 | ```php 29 | function languagelayer_batch($query_array) { 30 | 31 | // set access key 32 | $access_key = 'YOUR_ACCESS_KEY'; 33 | 34 | 35 | foreach($query_array as $value) { $fields_string .= 'query[]='.$value.'&'; } 36 | rtrim($fields_string, '&'); 37 | 38 | // Initialize CURL: 39 | $ch = curl_init('http://apilayer.net/api/batch?access_key='.$access_key); 40 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 41 | curl_setopt($ch, CURLOPT_POST, true); 42 | curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); 43 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 44 | 45 | // Store the data: 46 | $json = curl_exec($ch); 47 | curl_close($ch); 48 | 49 | echo $json; 50 | 51 | // Decode JSON response: 52 | $detection_results = json_decode($json, true); 53 | 54 | // Access and use your preferred validation result objects 55 | return $detection_results; 56 | 57 | } 58 | 59 | // set query texts 60 | $query_array = array('hey friend', 'hola amigo', 'hallo freund'); 61 | 62 | // store results array 63 | $results_array = languagelayer_batch($query_array); 64 | ``` 65 | --------------------------------------------------------------------------------