Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

detectlanguage

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

detectlanguage

Detect Language API Node.js Client

  • 2.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10K
increased by11.27%
Maintainers
1
Weekly downloads
 
Created
Source

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
  }
]

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

Keywords

FAQs

Package last updated on 05 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc