> This page is for Analytics API.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://documentation.babelstreet.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://documentation.babelstreet.com/_mcp/server.

# Identifies the language(s) in a document

POST https://analytics.babelstreet.com/rest/v1/language
Content-Type: application/json

Returns list of candidate languages in order of descending confidence. The response is an ordered list of identified languages, including language and identification confidence, sorted by descending confidence.

Reference: https://documentation.babelstreet.com/analytics/text-analytics/language-identification/identifies-the-language-s-in-a-document

## Authentication

- `X-BabelStreetAPI-Key` header (required) — API Key authentication via header
- `X-RosetteAPI-Key` header (required) — API Key authentication via header

## Servers

- `https://analytics.babelstreet.com/rest/v1` (https://analytics.babelstreet.com/rest/v1/, default)
- `https://api.rosette.com/rest/v1` (https://api.rosette.com/rest/v1/)

## Request

### Body (application/json)

This endpoint expects a LanguageRequest.

- `language` (string, optional) — 3 letter code of language.
- `options` (LanguageRequestOptions, optional)

## Response

### 200

OK

- `languageDetections` (list of LanguageDetectionResult, optional) — List of detected languages

## Types

### LanguageRequestOptions

- `koreanDialects` (boolean, optional, default: false)
- `multilingual` (boolean, optional, default: false)

### LanguageDetectionResult

- `language` (string, optional) — detected language
- `confidence` (double, optional) — detection confidence

## Examples

### JSON String

**Request**

```json
{
  "content": "Por favor Señorita, says the man"
}
```

**Response**

```json
{
  "languageDetections": [
    {
      "language": "string",
      "confidence": 1.1
    }
  ]
}
```

**SDK Code**

```python JSON String
import requests

url = "https://analytics.babelstreet.com/rest/v1/language"

payload = { "content": "Por favor Señorita, says the man" }
headers = {
    "X-BabelStreetAPI-Key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript JSON String
const url = 'https://analytics.babelstreet.com/rest/v1/language';
const options = {
  method: 'POST',
  headers: {'X-BabelStreetAPI-Key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"content":"Por favor Señorita, says the man"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go JSON String
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://analytics.babelstreet.com/rest/v1/language"

	payload := strings.NewReader("{\n  \"content\": \"Por favor Señorita, says the man\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-BabelStreetAPI-Key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby JSON String
require 'uri'
require 'net/http'

url = URI("https://analytics.babelstreet.com/rest/v1/language")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-BabelStreetAPI-Key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"content\": \"Por favor Señorita, says the man\"\n}"

response = http.request(request)
puts response.read_body
```

```java JSON String
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://analytics.babelstreet.com/rest/v1/language")
  .header("X-BabelStreetAPI-Key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"content\": \"Por favor Señorita, says the man\"\n}")
  .asString();
```

```php JSON String
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://analytics.babelstreet.com/rest/v1/language', [
  'body' => '{
  "content": "Por favor Señorita, says the man"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-BabelStreetAPI-Key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp JSON String
using RestSharp;

var client = new RestClient("https://analytics.babelstreet.com/rest/v1/language");
var request = new RestRequest(Method.POST);
request.AddHeader("X-BabelStreetAPI-Key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"content\": \"Por favor Señorita, says the man\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift JSON String
import Foundation

let headers = [
  "X-BabelStreetAPI-Key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["content": "Por favor Señorita, says the man"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://analytics.babelstreet.com/rest/v1/language")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### URI

**Request**

```json
{
  "contentUri": "https://en.wikipedia.org/wiki/Abd_Rabbuh_Mansur_Hadi"
}
```

**Response**

```json
{
  "languageDetections": [
    {
      "language": "string",
      "confidence": 1.1
    }
  ]
}
```

**SDK Code**

```python URI
import requests

url = "https://analytics.babelstreet.com/rest/v1/language"

payload = { "contentUri": "https://en.wikipedia.org/wiki/Abd_Rabbuh_Mansur_Hadi" }
headers = {
    "X-BabelStreetAPI-Key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript URI
const url = 'https://analytics.babelstreet.com/rest/v1/language';
const options = {
  method: 'POST',
  headers: {'X-BabelStreetAPI-Key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"contentUri":"https://en.wikipedia.org/wiki/Abd_Rabbuh_Mansur_Hadi"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go URI
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://analytics.babelstreet.com/rest/v1/language"

	payload := strings.NewReader("{\n  \"contentUri\": \"https://en.wikipedia.org/wiki/Abd_Rabbuh_Mansur_Hadi\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-BabelStreetAPI-Key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby URI
require 'uri'
require 'net/http'

url = URI("https://analytics.babelstreet.com/rest/v1/language")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-BabelStreetAPI-Key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"contentUri\": \"https://en.wikipedia.org/wiki/Abd_Rabbuh_Mansur_Hadi\"\n}"

response = http.request(request)
puts response.read_body
```

```java URI
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://analytics.babelstreet.com/rest/v1/language")
  .header("X-BabelStreetAPI-Key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"contentUri\": \"https://en.wikipedia.org/wiki/Abd_Rabbuh_Mansur_Hadi\"\n}")
  .asString();
```

```php URI
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://analytics.babelstreet.com/rest/v1/language', [
  'body' => '{
  "contentUri": "https://en.wikipedia.org/wiki/Abd_Rabbuh_Mansur_Hadi"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-BabelStreetAPI-Key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp URI
using RestSharp;

var client = new RestClient("https://analytics.babelstreet.com/rest/v1/language");
var request = new RestRequest(Method.POST);
request.AddHeader("X-BabelStreetAPI-Key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"contentUri\": \"https://en.wikipedia.org/wiki/Abd_Rabbuh_Mansur_Hadi\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift URI
import Foundation

let headers = [
  "X-BabelStreetAPI-Key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["contentUri": "https://en.wikipedia.org/wiki/Abd_Rabbuh_Mansur_Hadi"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://analytics.babelstreet.com/rest/v1/language")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```