Language Detection API Documentation

 

Language Detection API Implementation instructions

Note: please don't forget to check out the Code Resources for the Language Detection API! These provide code examples of the API implementations in several programming languages.

Language Detection API uses a JSON-based RPC format and can be accessed trough GET and POST interfaces over the world wide web. The API endpoint is located at:

http://api.ai-applied.nl/api/language_detection_api/

Note: All our API's allow demo and testing use for free. You can request an API key to test our API's using the form below, after which an API key with 5000 credits will be e-mailed to the provided e-mail address. The use of the API beyond this limit requires a commercial account and a API key. We will never share your e-mail address with anyone, and use it only to prevent the abuse of the demo functionality. At any time you can upgrade your demo key by adding purchased credits to it, or by switching to a subscription plan.

The API call can be passed in a JSON format using the POST or GET command:


request=
{
"data":{
"api_key":"your_api_key",
"call":{
"return_original":false,
"data":[
{
"text":"your_text",
"id":0
}
]
}
}
}

The API call contains the following parameters:

ParameterObligatoryDescription
dataYestransport container for the API call
api_keyYesyour key for the use of this API
callYesthe API call information container
return_originalNoreturn full posted messages (true) together with the language annotation or only the message id's (false) annotated with language
dataYesa list of JSON-dictionary formatted messages, or a link to a data source API returning such formatted messages

All messages passed in the final data parameter need to be JSON formatted like the following example:

{
"text":"Some message text",
"id":some_id
}

Every message needs to at least contain the "text" parameter, specifying the message's text as a string, and a "id" parameter, providing a unique ID for this message as a integer or a string.

NOTE: All Ai Applied API's are much more efficient in BATCH PROCESSING mode than when processing one message at the time. We encourage the sending of up to 20.000 messages at a time for processing, as larger batches incur additional bonuses in processing speed per message.

Sample call and response interpretation

This example requests from the Language Detection API the annotation of a message in English, Dutch, German and Russian. You can copy-paste the code below into your browser URL bar, or click here, to view the API response:

 

http://api.ai-applied.nl/api/language_detection_api/?request={
"data":{
"api_key":"DEMO_ACCOUNT",
"call":{
"return_original":true,
"data":[
{
"id":1,
"text":"This is a test"
},
{
"id":2,
"text":"Dit is een test"
},
{
"id":3,
"text":"Dies ist ein Test"
},
{
"id":4,
"text":"Давай к нам, у нас снега завались :)"
}
]
}
}
}

This call returns the following JSON formatted message:

{
"status":1,
"id":null,
"response":{
"data":[
{
"language_iso":"eng",
"text":"This is a test",
"confidence_language":0.9998800529838848,
"id":1,
"language_eng_name":"English"
},
{
"language_iso":"nld",
"text":"Dit is een test",
"confidence_language":0.9999991381857305,
"id":2,
"language_eng_name":"Dutch"
},
{
"language_iso":"deu",
"text":"Dies ist ein Test",
"confidence_language":0.9999999999910069,
"id":3,
"language_eng_name":"German"
},
{
"language_iso":"rus",
"text":"\u0414\u0430\u0432\u0430\u0439 \u043a \u043d\u0430\u043c, \u0443 \u043d\u0430\u0441 \u0441\u043d\u0435\u0433\u0430 \u0437\u0430\u0432\u0430\u043b\u0438\u0441\u044c :)",
"confidence_language":1.0,
"id":4,
"language_eng_name":"Russian"
}
],
"description":"OK: Call processed.",
"success":true
}
}

Following parameters in API reply belong to the transport layer, and can be stripped away in case of success:

ParameterDescription
statushas value 1 if the transport of the message has been conducted succesfully trough all systems
ida optional callback parameter that can be ignored for this API
responsecontains the response from the API classifiers

The "response" parameter contains this API's reply and consists of the following subparameters:

ParameterDescription
successindicates whether the API call has been completed with success (==true), or has failed (==false)
descriptiongives a description of the API call's success or failure as a string
datacontains a list of language annotated texts provided by the API in a JSON format

All messages returned in the data parameter are JSON formatted like the following example:

{
"language_iso":"eng",
"text":"This is a test",
"confidence_language":0.9999995481545861,
"id":1,
"language_eng_name":"English"
}

When the "return_original" parameter is set to true in the API call, the returned messages contain all parameters provided to the API in the call in addition to the annotation parameters. If the "return_original" parameter is set to false in the API call, only the following annotation parameters are returned:

ParameterDescription
language_isothe ISO-639-3 code of the detected language, or "unknown" if the language is unknown to the API
language_eng_namethe name of the language in English, or "unknown" if the language is unknown to the API
confidence_languagethe confidence the API has in it's judgement about the detected language on a scale 0-1

The results obtained from the Language Detection API can also be used as a part of further message processing by our API's, such as Sentiment Analysis API and Demographics API.

Note: please don't forget to check out the Code Resources for the Language Detection API! These provide code examples of the API implementations in several programming languages.

If you need more assistance with the implementation of this API, please don't hesitate to comment below, or contact us for assistance!