Jump to main content

Language Detection API

Detects the language of a given text and returns its ISO code.

Language Detection API

What is Language Detection?

A quick introduction

Finding out a text language can be much harder than it may seem. A first approach would be to have a dictionary of words from each language and choose the one with more words inside the dictionary.

Although this may seem feasible, we may encounter some problems: poorly written words, words in different languages… which may affect the overall detected language 🤥

Another approach would be the use of n-grams. Basically, you split each word into n-grams (for example, bigrams). For example, if we had the word "The" we would create the following bigrams: "_T", "Th", "he", "e_".

Once we have generated tons of n-grams, we can create a "profile" for a language, and match your text profile against each language profile to select the best fit. This idea was published by Cavnar and Trenkle in 1994

This is a great approach, although it doesn't seem to perform very well for short texts or handling unknown languages. In 2009, Radim Řehůřek and Milan Kolkus came up with another approach: create models based on word relevance.

Language detection can be used in lots of situations and can be a huge improvement to your application.

Down below you can see some use cases for this service.

What can you do with our Language Detection API?

We have written a few use cases to inspire you develop a smarter application!

Validate your HTML lang attribute
HTML documents have a [lang] attribute, but sometimes we may not provide the correct one.
Classify your user reviews and comments
Those having an online store or a blog posting platform of their own can make use of this API to automatically classify their user interactions based on user language.
Contact Forms
Same idea as before. This service can be used to add a new hint in the emails sent to the admin of your website to help them identify the user language.
Create a dashboard for your interactive platform and get insights about how many languages are your users speaking.

Start now with our PHP and JavaScript libraries

We have open-sourced our PHP and JavaScript libraries to make it extremely easy to start using our AI services.

Take me to the documentation
App screenshot

Frequently asked questions

What's the cost of using this service?

This service has a minimum cost of 2 credits per call. Please keep in mind that some of our services may charge based on the amount of characters.

What if I don't use PHP nor JavaScript?

We are still working on this to provide you with libraries in many other languages! In the meantime, you can use our API Endpoints and implement your own solution. It's still super easy!

Is there any free tier?

Once you sign up, you will get 100 free credits to use them whenever you want. We will never pressure you into purchasing something you are not completely sure you will need.

I've ran out of free credits and I'm still not convinced.

In this case you can get in touch with us and we can refill your free credits account for further API testing 🥳

I've accidentally leaked my API Key. What should I do?

Don't worry. You can go to your profile to reset your API Token and we will disable the previous one automatically.

Okay, you've convinced me. How do I start?

First of all, create an account if you haven't got one yet. Once you've got it, just click on the buy credits button on the top-right corner and you'll be all set up!

One new service each week

Get notified whenever we deploy a new artificial intelligence API endpoint. We promise we will not spam you and you can unsubscribe at any time.