# Language Detector: 75 languages, codes and confidence (`examsens.ai/language-detector`) Actor

Detects the language of many texts, web pages or dataset fields at once: language name, ISO 639-1 and ISO 639-3 codes, confidence, a reliability flag and the next candidates. Runs offline inside the actor.

- **URL**: https://apify.com/examsens.ai/language-detector.md
- **Developed by:** [Ed Rayyis](https://apify.com/examsens.ai) (community)
- **Categories:** AI, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.45 / 1,000 text analyzeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Language Detector: 75 languages, codes and confidence

Find out what language each text is written in. Paste texts, send JSON records with your own IDs, list web pages, or point it at an Apify dataset, and get one result per text with the language name, its ISO codes and how sure the detector is.

### What you get for each text

- `language`: the English name, such as German or Norwegian Bokmål
- `code`: ISO 639-1 (`de`) and `iso639_3`: ISO 639-3 (`deu`)
- `confidence`: from 0 to 1
- `reliable`: true when the confidence reaches your threshold (default 0.5) and leads the next language by at least 0.1. A short text can fall below it: "Bedankt voor je bestelling!" scores 0.40 for Dutch across all 75 languages, and 0.76 when the choice is limited to Dutch, German, Danish and Norwegian Bokmål.
- `candidates`: the top languages with their confidence, best first (default 3)
- `textPreview` (the first 120 characters) and `charCount`
- For web pages, `declaredLanguage`: the language the page's own `html` tag states, next to the language of its text

### Languages

Afrikaans, Albanian, Arabic, Armenian, Azerbaijani, Basque, Belarusian, Bengali, Bosnian, Bulgarian, Catalan, Chinese, Croatian, Czech, Danish, Dutch, English, Esperanto, Estonian, Finnish, French, Ganda, Georgian, German, Greek, Gujarati, Hebrew, Hindi, Hungarian, Icelandic, Indonesian, Irish, Italian, Japanese, Kazakh, Korean, Latin, Latvian, Lithuanian, Macedonian, Malay, Maori, Marathi, Mongolian, Norwegian Bokmål, Norwegian Nynorsk, Persian, Polish, Portuguese, Punjabi, Romanian, Russian, Serbian, Shona, Slovak, Slovenian, Somali, Southern Sotho, Spanish, Swahili, Swedish, Tagalog, Tamil, Telugu, Thai, Tsonga, Tswana, Turkish, Ukrainian, Urdu, Vietnamese, Welsh, Xhosa, Yoruba and Zulu.

When you know your texts can only be a few languages, list their ISO 639-1 codes. The detector then chooses among those alone, which helps most on short texts.

### Input

- Texts: one per entry
- Texts with IDs: JSON objects such as `{"id": "review-17", "text": "...", "stars": 5}`. Every field except the text is copied to the result, so you can join it back.
- Web pages: the main text of each page is detected. Menus, footers and scripts are left out.
- Apify datasets: each item is one text. The field is found for you (`text`, `markdown`, `content`, `body`, `description`, `title`, `review`, `comment`), or name it.
- Limit to languages, candidates per text, reliable at confidence, fewest letters (default 3), fast mode

### Output

Dataset: one item per text, in input order, with `index` and `id`. A text with fewer letters than the minimum, such as "ok" or "12345", gets `language: null` and a `note`. A source that cannot be read gets `ok: false` and an `error`, such as `HTTP 404` or a record with no text. The other texts still run.

### Pricing

Pay per event: one event per text with a detected language. Texts too short to detect and sources that fail are not charged. The run stops when it reaches the maximum charge you set.

### How it works

Detection runs inside the actor with the open source Lingua library (Apache 2.0 license). No text is sent to any outside service, and nothing is stored beyond the run's own storage.

### Support

Questions and problems: the Issues tab on this page. Replies are written by an AI assistant on behalf of the developer and reviewed by the developer.

# Actor input Schema

## `texts` (type: `array`):

One text per entry.

## `items` (type: `array`):

JSON objects with "text" and any other fields, such as an "id". The other fields are copied to the result so you can join it back to your data.

## `urls` (type: `array`):

Pages whose main text is detected. Menus, footers and scripts are left out.

## `datasetIds` (type: `array`):

Datasets in your account; each item is one text. The field is found for you (text, markdown, content, body, description, title, review, comment), or set it below.

## `textField` (type: `string`):

Field of each dataset item to read.

## `languages` (type: `array`):

ISO 639-1 codes, such as en, de, fr. When you know the texts can only be a few languages, listing them gives better results on short texts. Leave empty for all 75.

## `candidates` (type: `integer`):

How many languages to list, best first.

## `reliableConfidence` (type: `string`):

A result is marked reliable when its confidence reaches this value (0 to 1) and leads the next language by at least 0.1.

## `minLetters` (type: `integer`):

Texts with fewer letters get no language and are not charged.

## `lowAccuracyMode` (type: `boolean`):

Use smaller models: faster, and less accurate on short texts.

## Actor input object example

```json
{
  "texts": [
    "Der schnelle braune Fuchs springt über den faulen Hund.",
    "El envío tarda entre tres y cinco días hábiles.",
    "Merci pour votre commande, elle arrive demain.",
    "Bedankt voor je bestelling!"
  ],
  "candidates": 3,
  "reliableConfidence": "0.5",
  "minLetters": 3,
  "lowAccuracyMode": false
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "texts": [
        "Der schnelle braune Fuchs springt über den faulen Hund.",
        "El envío tarda entre tres y cinco días hábiles.",
        "Merci pour votre commande, elle arrive demain.",
        "Bedankt voor je bestelling!"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("examsens.ai/language-detector").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "texts": [
        "Der schnelle braune Fuchs springt über den faulen Hund.",
        "El envío tarda entre tres y cinco días hábiles.",
        "Merci pour votre commande, elle arrive demain.",
        "Bedankt voor je bestelling!",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("examsens.ai/language-detector").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "texts": [
    "Der schnelle braune Fuchs springt über den faulen Hund.",
    "El envío tarda entre tres y cinco días hábiles.",
    "Merci pour votre commande, elle arrive demain.",
    "Bedankt voor je bestelling!"
  ]
}' |
apify call examsens.ai/language-detector --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,examsens.ai/language-detector"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/U7xO1zTBQ2dTQPaeq/builds/h65nHpsSZGd6LCveW/openapi.json
