detectlanguage
Detect Language API Node.js Client
Last updated 7 months ago by kurmisrainas .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install detectlanguage 
SYNC missed versions from official npm registry.

Detect Language API Node.js Client

npm version Build Status

Node.js wrapper for the Detect Language API.

Installation

npm install detectlanguage [--save]

Configuration

Before using Detect Language API client you have to setup your personal API key. You can get it by signing up at detectlanguage.com

var DetectLanguage = require('detectlanguage');

var detectlanguage = new DetectLanguage('YOUR API KEY');

Usage

Language Detection

Takes a text string and returns a list of detections.

var text = "Hello! How are you?";

detectlanguage.detect(text).then(function(result) {
  console.log(JSON.stringify(result));
});

Response

[
  {
    "language": "en",
    "isReliable": true,
    "confidence": 18.2
  }
]

Batch Detection (recommended)

Takes an array of texts and returns a list of detections. It is much faster than doing request for each text individually.

var texts = ['šešios žąsys', 'Strč prst skrz krk'];

detectlanguage.detect(texts).then(function(result) {
  console.log(JSON.stringify(result));
});

Response

[
  [
    {
      "language": "lt",
      "isReliable": true,
      "confidence": 5.5
    }
  ],
  [
    {
      "language": "cs",
      "isReliable": true,
      "confidence": 3.645
    },
    ...
  ]
]

Language Code Detection

Returns first detected language code.

var text = "Hello! How are you?";

detectlanguage.detectCode(text).then(function(result) {
  console.log(JSON.stringify(result));
});

Response

"en"

Supported Languages

Returns the list of supported languages.

detectlanguage.languages().then(function(result) {
  console.log(JSON.stringify(result));
});

Response

[
  {
    code: "aa",
    name: "AFAR"
  },
  {
    code: "ab",
    name: "ABKHAZIAN"
  },
  {
    code: "af",
    name: "AFRIKAANS"
  }
  ...
]

User Status

Returns information about your account and it's status.

detectlanguage.userStatus().then(function(result) {
  console.log(JSON.stringify(result));
});

Response

{
  date: "2020-01-01",
  requests: 31,
  bytes: 429,
  plan: "FREE",
  plan_expires: null,
  daily_requests_limit: 1000,
  daily_bytes_limit: 1048576,
  status: "ACTIVE"
}

Author

Laurynas Butkus (GitHub)

License

Licensed under the MIT License: https://opensource.org/licenses/MIT

Current Tags

  • 2.1.0                                ...           latest (7 months ago)

11 Versions

  • 2.1.0                                ...           7 months ago
  • 2.0.0                                ...           a year ago
  • 1.2.2                                ...           3 years ago
  • 1.2.1                                ...           4 years ago
  • 1.2.0                                ...           4 years ago
  • 1.1.0                                ...           7 years ago
  • 1.0.4                                ...           7 years ago
  • 1.0.3                                ...           7 years ago
  • 1.0.2                                ...           7 years ago
  • 1.0.1                                ...           7 years ago
  • 1.0.0                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 2
Dependencies (1)
Dev Dependencies (14)

Copyright 2014 - 2021 © npmmirror.com |