Language Detector API

Description

Parse a text piece to detect the language it was written in. This endpoint supports 50+ languages.

Endpoint

> GET https://api.jsonrepo.com/v1/compute/parser/language

Headers

Field Description
api_key Required Your API Key

Parameters

Field Type Description
text String Required The text to parse
Maximum: 1000 characters

Text Encoding:

The text parameter is UTF-8 ready. Any non-english characters can be sent as is without any pre-processing or conversions on your end. Example: the Swedish text "Jag är en katt" will be accepted by this endpoint as long as the parameter was provided with the correct URL-encoding.

See the example section for more information.

Text Size Limitations:

We enforce a 1000 multi-byte character limit on the text parameter. In most cases, it takes a lot less than that for detection to work its magic. Be sure to respect this upper limit as certain HTTP clients tend to truncate GET parameters when the URL exceeds a certain size.

Response

A successful request will result in a populated payload field with the expected output.

A failed request will result in an error output as detailed in Error Rules. If the endpoint validation fails due to missing, badly formatted or invalid parameters, the endpoint will return HTTP code 400 along with a message detailing the error.

See the examples section for more information.

Request

  • Curl
// Parse a German piece of text

curl -G \
https://api.jsonrepo.com/v1/compute/parser/language \
-H "api_key: {YOUR_API_KEY_HERE}" \
--data-urlencode "text=Der König ist nackt, ich schwöre"

Success Response

{
    "http_code": 200,
    "http_message": "Ok",
    "message": "Successful execution",
    "payload": {
        "text": {
            "found_match": true,
            "best_match": {
                "iso": "DE",
                "name": "German"
            },
            "scores": [
                {
                    "iso": "DE",
                    "name": "German",
                    "score": 0.4979876893939394
                },
                {
                    "iso": "TR",
                    "name": "Turkish",
                    "score": 0.12758049242424244
                },
                {
                    "iso": "SV",
                    "name": "Swedish",
                    "score": 0.1259469696969697
                },
                {
                    "iso": "DA",
                    "name": "Danish",
                    "score": 0.08006628787878788
                },
                {
                    "iso": "SK",
                    "name": "Slovak",
                    "score": 0.06534090909090909
                }
            ]
        }
    }
}

Error Response Examples

// Request with missing OR too large `text` parameter

{
    "http_code": 400,
    "http_message": "Bad Request",
    "message": "Malformed request: `text` parameter must be provided and not exceed 1000 characters",
    "payload": []
}