
The difference between a really successful application and one not so successful is often the number of languages it can support. in fact, having multi-language support in your software makes your application much more likely to be welcomed by millions of people around the world.
LanguageLayer is one of the market-leading language detection RESTful web services. LanguageLayer is powered by AI and also supports 173 languages. Using ip geolocation can also be useful to location a user’s country.
Table of Contents
Simple, Quick, Reliable & AI-Powered Language Detection
LanguageLayer API Features:
- Accurate, Efficient & Lightning Fast automated language detection using any programming language
- Easy-to-use REST API delivered in lightweight JSON format
- Single language detection queries or batch detection
- No queueing
- No server load
- Inexpensive subscription types
- Free subscription plan to test the LanguageLayer service
How do I integrate LanguageLayer API?
The LanguageLayer API is built upon a RESTful and easy-to-understand request and response structure. API requests always use a simple API request URL with a series of required and optional HTTP GET parameters.
Want to get started? First, you need to get your free API access key. After that, you can send requests to the endpoint:


How to do batch detection?
The LanguageLayer API also processes 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 the query into the API request URL:

After executing this batch request, the API returns single or multiple language detection results for each requested query text. Languagelayer returns results in the same order you specified in the API request.

How to start a Node.js web app?
In this demonstration, we will create a simple Node.js app that fetches data from the LanguageLayer API and shows it to a user.
How to set up Node.js with LanguageLayer API?
Open your PowerShell or Bash if you are using Linux and type these commands to set up basic files for the project:

Now, go back to your terminal and write these commands to install the packages our project requires. It installs Express, axios and body-parser, as well as EJS.


Next, make sure you have these files and project folder structure.

Here is our Node.js web app source code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
const express = require('express') const app = express() const port = 2505 app.use(express.static('public')) app.use('/css', express.static(__dirname + 'public/css')) app.use('/js', express.static(__dirname + 'public/js')) app.set('views', './src/views') app.set('view engine', 'ejs') // set the router for /detect endpoint const detectRouter = require('./src/routes/detect') app.use('/detect', detectRouter) app.listen(port, () => console.log(`Listening on port ${port}`)) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
const express = require('express') const detectRouter = express.Router() const axios = require('axios') detectRouter.get('', async(req, res) => { try{ // lookup given query const response = await axios.get('https://api.languagelayer.com/detect?access_key=f3d276ac0beac680f6a2a6eeb640102c&query=programming') // send json response to embedded js res.render('detect', { detectedData : response.data.results }) // data is here json } catch (error) { if(error.response) { console.log(error.response.data) } else if(error.request) { console.log(error.request) } else { console.log('Error', error.message) } } }); module.exports = detectRouter |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no"> <title>Language Layer API + Node.js</title> <link rel="stylesheet" href="css/bootstrap.min.css"> <link rel="stylesheet" href="https://fonts.googleapis.com/css?display=swap&family=Lato:300,400,700"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pikaday/1.6.1/css/pikaday.min.css"> </head> <body> <nav class="navbar navbar-dark navbar-expand-lg fixed-top bg-white portfolio-navbar gradient"> <div class="container"><a class="navbar-brand logo" href="#">Language Layer API + Node.js</a><button data-bs-toggle="collapse" class="navbar-toggler" data-bs-target="#navbarNav"><span class="visually-hidden">Toggle navigation</span><span class="navbar-toggler-icon"></span></button> <div class="collapse navbar-collapse" id="navbarNav"> <ul class="navbar-nav ms-auto"></ul> </div> </div> </nav> <main class="page projets-page"> <section class="portfolio-block project-no-images"> <div class="container"> <div class="heading"> <h2>Language Detection</h2> </div> <% detectedData.forEach(function(result, index) { %> <div class="row"> <div class="col-md-6 col-lg-4"> <div class="project-card-no-image"> <h3>Language Code</h3> <h4> <%- result.language_code %> </h4> </div> </div> <div class="col-md-6 col-lg-4"> <div class="project-card-no-image"> <h3>Language Name</h3> <h4> <%- result.language_name %> </h4> </div> </div> <div class="col-md-6 col-lg-4"> <div class="project-card-no-image"> <h3>Probability</h3> <h4> <%- result.probability %> </h4> </div> </div> <div class="col-md-6 col-lg-4"> <div class="project-card-no-image"> <h3>Percentage</h3> <h4> <%- result.percentage %> </h4> </div> </div> <div class="col-md-6 col-lg-4"> <div class="project-card-no-image"> <h3>Reliable Result</h3> <h4> <%- result.reliable_result %> </h4> </div> </div> </div> <% }) %> </div> </section> </main> <footer class="page-footer"> <div class="container"> <div class="links"><a href="#">Language Layer API</a></div> <div class="social-icons"><a href="#"><i class="icon ion-social-facebook"></i></a><a href="#"><i class="icon ion-social-instagram-outline"></i></a><a href="#"><i class="icon ion-social-twitter"></i></a></div> </div> </footer> <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/pikaday/1.6.1/pikaday.min.js"></script> <script src="js/script.min.js"></script> </body> </html> |
Finally, this is the result:

It really is that simple to autodetect languages. Want to see more or try it yourself? Check out the whole project in this repository.
To learn more about Languagelayer API, head over to get your free subscription plan!